Folks, I get irritated by the way resources (mainly styles) can accumulate inside the XAML for controls and windows, often making a huge mess. I ran an experiment to evaluate a possible way of pulling most of the resources out controls and putting them in separate xaml files. My choice was to have lines like these in each control:
<UserControl.Resources x:Key="DoNotDoThis"> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/WpfResTest.Common;component/CommonDictionary.xaml"/> <ResourceDictionary Source="ResourcesForThisProject.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> The first dictionary lives in its own project and contains global stuff used anywhere (I prefer not to put it in App.xaml). The second is for resources used anywhere within this project. I thought this was neat and created a sanity check solution, and after working around some quirks I think it's working okay. One gotcha is "Do not put an x:Key on the <ResourceDictionary> element" (my yellow highlight). I had one by accident and it caused the designer to ignore the styles and I got spurious XAML markup warnings. Luckily I found this error when by a whim I tried to open it in Blend and it explained the problem clearly. Does anyone object to my convention or have neater alternatives? Cheers, Greg