Design-time Resources in Expression Blend 4 RC
When building Silverlight and WPF applications that are composited (e.g. using MEF) or written to support UI customization, resources are loaded dynamically at run-time. This is a great solution on the development side, but can be a challenge when working on design tasks. If your design surface can’t find the resources at design-time you are presented with zero styling or worse, XAML parsing errors.
Expression Blend 4 RC provides a new feature to support loading resources at design-time.
When you open a project in Blend and the current document contains resources that cannot be resolved and your solution contains at least one ResourceDictionary file, the Add Design-time Resource Dictionary dialog will open.
Once selected, a reference to the dictionary will be added to a file named “DesignTimeResources.xaml” located under the Properties folder. Blend will now find the missing resources during design-time and be able to render the design surface properly.
This feature enables editing of dynamic applications to be much easier than before. No more hacks to get your resources loaded!
As a side note, if you’ve added a ResourceDictionary as a design-time resource and you’d like to remove it; open the “DesignTimeResources.xaml” file. In XAML view, remove the reference to your resource dictionary in the ResourceDictionary.MergedDictionaries node. Then after closing and reopening the file referencing the missing resources, the dialog will prompt you again to choose a dictionary.
I’ve provided a sample solution below that will prompt you with the Add Design-time Resource Dictionary dialog, when you open the “MainPage.xaml” file.