Can WPF themes be used to include multiple skins for an application that can be changed at runtime?

Here is a snippet of code that I used in my application that supported theming. In this example, I have two themes (Default and Classic XP). The theme resources are stored in the DefaultTheme.

Xaml and ClassicTheme. Xaml respectively This is the default code in my App. Xaml Application ...> Xaml I have the following method to allow for changing the theme.

Basically, what you do is clear the Resource Dictionaries and then reload the dictionary with the new theme private Themes _currentTheme = Themes. Default; public Themes CurrentTheme { get { return _currentTheme; } set { _currentTheme = value; } } public void ChangeTheme(Themes theme) { if (theme! = _currentTheme) { _currentTheme = theme; switch (theme) { default: case Themes.

Default: this.Resources. MergedDictionaries.Clear(); AddResourceDictionary("ArtworkResources. Xaml"); AddResourceDictionary("DefaultTheme.

Xaml"); break; case Themes. Classic: this.Resources. MergedDictionaries.Clear(); AddResourceDictionary("ArtworkResources.

Xaml"); AddResourceDictionary("ClassicTheme. Xaml"); break; } } } void AddResourceDictionary(string source) { ResourceDictionary resourceDictionary = Application. LoadComponent(new Uri(source, UriKind.

Relative)) as ResourceDictionary; this.Resources. MergedDictionaries. Add(resourceDictionary); } What you'll also need to keep in mind with this approach is that any styles that utilize a theme will need to have a dynamic resource.

For example: Window Background="{DynamicResource AppBackgroundColor}.

Here is a snippet of code that I used in my application that supported theming. In this example, I have two themes (Default and Classic XP). The theme resources are stored in the DefaultTheme.

Xaml and ClassicTheme. Xaml respectively. This is the default code in my App.

Xaml Then in the code behind of the App. Xaml I have the following method to allow for changing the theme. Basically, what you do is clear the Resource Dictionaries and then reload the dictionary with the new theme.

Private Themes _currentTheme = Themes. Default; public Themes CurrentTheme { get { return _currentTheme; } set { _currentTheme = value; } } public void ChangeTheme(Themes theme) { if (theme! = _currentTheme) { _currentTheme = theme; switch (theme) { default: case Themes.

Default: this.Resources. MergedDictionaries.Clear(); AddResourceDictionary("ArtworkResources. Xaml"); AddResourceDictionary("DefaultTheme.

Xaml"); break; case Themes. Classic: this.Resources. MergedDictionaries.Clear(); AddResourceDictionary("ArtworkResources.

Xaml"); AddResourceDictionary("ClassicTheme. Xaml"); break; } } } void AddResourceDictionary(string source) { ResourceDictionary resourceDictionary = Application. LoadComponent(new Uri(source, UriKind.

Relative)) as ResourceDictionary; this.Resources. MergedDictionaries. Add(resourceDictionary); } What you'll also need to keep in mind with this approach is that any styles that utilize a theme will need to have a dynamic resource.

For example.

I don't know of a way of doing this in the framework, but you can do it if you style every control that can change yourself. The theory is to make the style a DynamicResource and then load the ResourcesDictionary based on the users configuration for the different style. Here is an article that has an example.

Here is a snippet of code that I used in my application that supported theming. In this example, I have two themes (Default and Classic XP). The theme resources are stored in the DefaultTheme.

Xaml and ClassicTheme.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions