Lately I have been immersed in the world of MVVM/Silverlight and often Prism. But in this world the design elements can’t be pushed aside. I admit it … I am a developer who has fallen in love with Blend! So I was pretty unhappy (Ok, I was very frustrated) when I started using Prism apps and breaking the apps into separate decoupled modules and found that Blend could not see the resources at design time. Basically, I usually have a handful of projects (modules) and they are completely decoupled from each other. Only 1 has need for an App.xaml, the shell module. This works great … except that the modules without the app.xaml cannot see the resource at design time in Blend. I am not willing to give up using Blend to design, so I started searching the web and asking some experts on the Blend team about options.
It quickly became obvious to me that the adoption of Prism developers who use the completely decoupled module loaders and Blend users were not as large as I had thought. For the issue to be a problem you have to develop with Silverlight and Prism, choose to use the module catalogs to load the apps, use Unity, refrain from referencing projects directly, and design with Blend. Luckily I found some excellent help from the Blend’y guys (Peter Blois and Bob Brumfield) and Prism’y guys (Glenn Block). The solution is from their excellent advice and is as follows:
- Put all the resources in resource dictionaries (I chose to put them in my infrastructure project, but that is up to you)
- Add an app.xaml to each module (project)
- Add a link to the resource dictionary in each of the app.xaml files.
- Go to this link and follow the instructions that tell you how to add some lines to your csproj (or vbproj) files for the modules with app.xaml files. This will tell Blend to use them and to ignore the app.xaml files when you compile.
So you end up with the best of both world: you get to design in Blend and ignore the extra app.xaml’s when you compile/build.
Hope this helps!