views:

386

answers:

1

Hi, I've spent hours working on an application design in WPF and created a whole bunch of different styles along the way. But I noticed that I actually had just edited the styles in the SimpleStyles.xaml file and not a custom dictionary.

So, I started right clicking all controls I could find and selected "edit a copy" and created a copy in a custom resource dictionary. But then I found that alot of the controls are based on several styles. SimpleScrollViewer e.g contains both the thumb and probably more. This created a huge mess in the overall structure of styles in the entire project.

And thus, my question is as follows; What should I think about when doing this project from scratch again? Is it best to edit a copy of the SimpleStyles controls? Is there a tool of some sort to manage stuff like this?

A: 

Expression Blend will add a resource dictionary for the Simple Styles the first time you use a SimpleStyled control. For real world projects it is best practice to separate resource dictionaries by resource type and then functional area.

For example you will have horizontal resource dictionaries that fall into the following categories:

  1. Brushes
  2. Control Styles
  3. Converters / Selectors

Since these are horizontal their filenames are pretty self-explanatory (e.g. Brushes.xaml, ControlStyles.xaml, Converters.xaml, etc.)

If you are using Silverlight you should probably think about using Themes. In which case you would create Brushes.xaml and ControlStyles.xaml for each [themeName]\generic.xaml you create.

Then you should create resource dictionaries for functional areas that will house the following things:

  1. Item Templates for various ItemsControls used.
  2. Content Templates for various ContentControls used.
  3. One off Control Styles

Each functional area would have a resource dictionary that had the above items (e.g. CustomerManagementStyles.xaml, Orderingstyles.xaml, etc.)

markti