Home > Client Technologies > Design-time Resources in Expression Blend 4 RC

Design-time Resources in Expression Blend 4 RC

May 4, 2010

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.

Add Design-time Resource Dictionary dialog

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.

Download the Design-time Resource Sample

About these ads
  1. May 4, 2010 at 7:32 am

    this is going to save us a ton of headaches, thanks a bunch for showing how it works.. i know that blend 4 can support SL3 apps, does this specific functionality work for SL3 apps as well, or would this only work for an SL4 app? thanks again.

    • May 4, 2010 at 8:03 am

      Good question, and the answer is YES, it works the same way with Silverlight 3 projects.

      I should put together a post of all the Blend 4 features that are useful for Silverlight 3 apps and title it “Upgrade today!”

      • May 4, 2010 at 9:12 am

        sweet, thanks again

  2. Theo Albers
    June 7, 2010 at 3:49 am

    Hi,

    This would be an extremely usefull feature within Visual Studio 2010 as well. Do you know when this feature will be lifted to VS2010?

  1. May 5, 2010 at 4:27 am
Comments are closed.
Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: