Monday, 15 February 2010

c# - Trying to access style info by StaticResource through ResourceDictionary with x:Key -



c# - Trying to access style info by StaticResource through ResourceDictionary with x:Key -

i'm having problem wpf resources accessing external style info in external resourcedictionary through staticresources.

i have inherited bunch of code uses lot of dynamicresources in wpf style info shared.xaml. rather them staticresources designer view becomes useful. discovered can add together resourcedictionary in .resources of thing, works fine unless there .resources using in wpf. in case told need add together x:key resourcedictionary. except don't know how utilize key find resources statically.

minimal example:

<usercontrol x:class="myclass" ...> <usercontrol.resources> <resourcedictionary x:key="shared.xaml" source="/exteralresource;component/shared.xaml"/> <booleantovisibilityconverst x:key="booltovis"> </usercontrol.resources> <textblock background="{staticresource brushfromsharedxaml}" /> <!-- never finds brushsharedxaml --> </usercontrol>

any ideas?

<usercontrol.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="/exteralresource;component/shared.xaml"/> </resourcedictionary.mergeddictionaries> <booleantovisibilityconverst x:key="booltovis"> </resourcedictionary> </usercontrol.resources>

though, aware doing in each usercontrol going eat lot of ram, because you're creating new instance of shared.xaml resourcedictionary every instance of command @ runtime. should take @ sharedresourcedictionary

c# wpf xaml

No comments:

Post a Comment