wpf - Static resource shared in merged dictionaries -


i'm working on having dictionaries of styles , templates can dynamically apply application. before "new wanted" dynamical behavior, had several resource dictionaries, 1 each styled control, merged in app.xaml:

<application.resources>     <resourcedictionary>         <resourcedictionary.mergeddictionaries>             <resourcedictionary source="colorsdictionary.xaml"/>             <resourcedictionary source="controlstemplatesdictionary.xaml"/>         </resourcedictionary.mergeddictionaries>     </resourcedictionary> </application.resources> 

now, i'd application styled, decided merge previous resources new 1 called "myfirsttemplates" , add dictionary app.xaml.

new dictionary "myfirsttemplates.xaml":

<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">"     <resourcedictionary.mergeddictionaries>         <resourcedictionary source="colorsdictionary.xaml"/>         <resourcedictionary source="controlstemplatesdictionary.xaml"/>     </resourcedictionary.mergeddictionaries> </resourcedictionary> 

new app.xaml:

<application.resources>     <resourcedictionary>         <resourcedictionary.mergeddictionaries>             <resourcedictionary source="myfirsttemplates.xaml"/>         </resourcedictionary.mergeddictionaries>         <style targettype="{x:type window}"/>     </resourcedictionary> </application.resources> 

note: default style window correct bug of wpf 4, see adding merged dictionary merged dictionary

now have made change, cannot use color resource "colorsdictionary.xaml" staticresource in "controlstemplatedictionary.xaml" anymore. if change merging these files in app.xaml, works. make work, have change these staticresource dynamicresource. have idea why doesn't work anymore?

thank :-)

by moving dictionaries out of app.xaml resources each dictionary aren't in other's resource tree during loading of myfirsttemplates.xaml. original setup first loaded colorsdictionary available through app resources controlstemplatesdictionary while loaded. in new setup, in order color resource available in app resources needs loaded through myfirsttemplates, in turn requires loading of both dictionaries, in turn requires access color resource... it's sort of infinite loop of references can't resolved statically. dynamicresource can wait until loaded , access color without issue.

to fix either use dynamic or merge colorsdictionary directly controlstemplatesdictionary.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -