c# - Is it possible to get resource based on target type in WinRT platform -


in wpf can able style based on target type, below:

control.style = (style)toplevelcontrol.tryfindresource(typeof(control)) 

but in winrt can't that. can use key resource. possible resource based on target type? please me resolve this.

thanks in advance

the main difference between wpf , winrt dealing resources here findresource() , siblings in wpf objects, while in winrt have resources property.

the basic technique, object type used key targettype styles, still works though. here's simple helper extension method want:

public static object tryfindresource(this frameworkelement element, object key) {     if (element.resources.containskey(key))     {         return element.resources[key];     }      return null; } 

call in wpf:

control.style = (style)toplevelcontrol.tryfindresource(control.gettype()); 

(note original example not compile, control variable, , can't use typeof on variable. i've fixed bug in above example call).


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -