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
Post a Comment