wpf - XAML - MergedDictionaries throwing XmlParseException "item has already been added". Why? -


i have following, easy reproduce problem: i'm creating xaml application uses resources file. way go create mergeddictionaries-tag merge local , global resources, this:

<window> <window.resources>     <resourcedictionary>         <resourcedictionary.mergeddictionaries>             <resourcedictionary source="path.to.xaml.file"/>             <resourcedictionary>                 <style targettype="{x:type border}" x:key="typeblock">                  </style>                 <style targettype="{x:type border}" x:key="setblock">                  </style>             </resourcedictionary>         </resourcedictionary.mergeddictionaries>     </resourcedictionary> </window.resources> .... </window> 

this little piece of code crash if run it:

item has been added. key in dictionary: 'system.windows.controls.border'  key being added: 'system.windows.controls.border' 

if remove mergeddictionaries-tag, code run expected:

<window> <window.resources>     <style targettype="{x:type border}" x:key="typeblock">      </style>     <style targettype="{x:type border}" x:key="setblock">      </style> </window.resources> </window> 

i don't understand why throws exception when use merged resources. off course, fix easy enough (move resources lower level). nice know if 'normal' behavior...

if resources not located in separate file, shouldn't part of merged dictionaries. move them outside this:

<window.resources>     <resourcedictionary>         <resourcedictionary.mergeddictionaries>             <resourcedictionary source="path.to.xaml.file"/>         </resourcedictionary.mergeddictionaries>          <style targettype="{x:type border}" x:key="typeblock">          </style>         <style targettype="{x:type border}" x:key="setblock">          </style>     </resourcedictionary> </window.resources> 

that said, error message little misleading , may result of bug in xaml compiler.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -