tags:

views:

133

answers:

1

I have created something like this and this.
In effect I have a dll which supplies me with a "styler" for my application - it contains all my basic styles as well as a factory to call StylerFactory.DefaultStyler.ApplyStyles(this) on an Application - which merges the supplied ResourceDictionaries with the existing. This way I don't need all the basic styles in my components, nor do I need explicit references to my sesource-xaml-files.
Now - while this is working real good. The Styles are (obviously) not visible during design-time To my questions:

  1. Was that approach wise, or would it have been better to deploy xaml-resources and use them in every app/window/control ?
  2. Does someone see any possibility to apply my styles to the design-time display of VS2008 ?
A: 

In my opinion, it's an acceptable approach. The reason being, I haven't seen a better method.

In my own cases, I've loaded resource dictionaries at runtime using the code I described here, which I would assume would work for loading resources from other assemblies as well. The drawback is that the designer will not run this code first, meaning no style is applied by default, what you're experiencing.

To counteract this, I added a default <ResourceDictionary.MergedDictionaries> definition in each of my <Window.Resources> that I needed to edit at design-time. While this ends up being a bit redundant, this allowed me to have a working design-time Window while the proper MergedDictionary can be loaded later during runtime. Perhaps you can use this to find a better method.

Will Eddins
Will, what your describing at question #786183 is quite what I am doing, however I have the xaml files as embedded resources. So to do as you suggested I'd have to duplicat the resource-files, too...
Nils
Even with the resource file as an embedded resource in another DLL, I would think including the resource as stated in http://stackoverflow.com/questions/946869/is-it-possible-to-share-a-resourcedictionary-file-between-multiple-projects should work. Have you tried this and found that it doesn't?
Will Eddins
Yes and no, sure - If I included the ressources the designer will show them, but then i'd have the resources doubled and trippeled. I'm beginning to thing it had been better to simply build one xaml-file, included in the source using svn:external - that way I make sure there's only one "real" copy, and have the designer display the changes...
Nils