tags:

views:

725

answers:

3

Ok, I'm working on an application that will allow you to switch themes at runtime. So far so good with all the controls and what not. However my Window object will not apply any of the base items. Here is an example of the xaml from one of my resource dictionaries.

<SolidColorBrush x:Key="GrayBrush" Color="Gray" />
<SolidColorBrush x:Key="OrangeBrush" Color="Orange" />

<!-- Window Styles -->
<Style TargetType="{x:Type Window}">
    <Setter Property="Background" Value="{DynamicResource GrayBrush}" />
</Style>

I have my primary theme which has the above snippet in my app.xaml resource list as well. Now when the app starts the background is not applied nor when I change the resource dictionaries at runtime. I figure I am either missing something or it just don't work.

I'm using .net 3.5 and I'm just using the standard window object from the framework so I'm not inheriting from any other base control. What I'm trying to do is keep from having to specify a style or other attribute on the window object as I'm also allowing you to switch to the included themes like Aero, Luna, Classic, etc.

I just cannot for the life of me get the window to use the style.

The only thing that works, but does not change when switched, is if I set either a Style or Background attribute which is what I don't want to do.

Also, when I change themes this is how it's done:

Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(dictionary);

The dictionary is a resource dictionary loaded based on the theme selected from either the .net stuff or my own. This all appears to work fine just cannot get the window to work.

Any help would be greatly appreciated.

Thanks.

Any thoughts.

UPDATE: What I really want is a way for the Window object to change without having to change or set any additional properties on the window. It kind of defeats the purpose if I have to add a style tag or what not to all the window objects in my app.

A: 

Have a look here ...

http://www.codeplex.com/wpfthemes

If you download the source code you'll find they've implemented dynamic themes, also all the themes are free to use and theres some really nice ones.

Andy Clarke
I have actually been through that as well as the one in the wpf futures stuff. However none do what I'm looking for. The one you specify actually requires you to set properties on the form to set the styles. This won't work if I want to also use the prebuilt packaged themes. I've tried.
Joshua Cauble
A: 

did you get your window level theme working?

atadha