Folks, I modified a WPF app recently to use
ResourceDictionary.MergedDictionaries in most the controls so I could put
shared resources and styles in a shared library project. So I have lines
like this as I described last week:

 

<ResourceDictionary>

    <ResourceDictionary.MergedDictionaries>

        <ResourceDictionary
Source="FooApp.Common;Component/CommonDictionary.xaml" />

        ...

    </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

 

There is something subtly and terribly wrong with the Source line above (can
anyone see it immediately?). In VS2010 and Blend 4 you can design controls
okay, but when they are nested the designers fail and tell you the resource
is not found. This problem was so irritating that I knocked-up a mini
solution to demonstrate it to ask the group if anyone could figure out what
was wrong. Well, the mini sample worked.

 

So after days of puzzling over why the big app worked and the mini one
didn't, I stumbled across the difference ... You have to put a leading /
before the resource Uri like Source="/FooApp..." I see that online articles
do the correct thing, but I accidentally forgot the / and dug a hole for
myself. It's terrible that such a tiny mistake can waste so many man-hours.

 

Greg

 

 

Reply via email to