MahApps/MahApps.Metro — pull request #1151 by Tide (2014-03-12 20:32:16+00:00)
Title: Added support for changing the theme base for an application.

This will allow users to change the light and dark resources of the ThemeManager. This makes it possible to add new themes in an application and have the ThemeManager load them. This will not break any current code. It only adds features to the ThemeManager.

Note: This will only work for an application with application resources. There is no method to do this for window resources as that is not possible at the moment due to flyouts referencing the ThemeManager's Light and Dark Resources.

To use it you would create a resource dictionary for a light resource and a dark resource in your application. You could then call the following to change the resources for the application:
```csharp
ThemeManager.ChangeBaseTheme(Application.Current, baseLightResource, baseDarkResource);
```
or the following to change the resources for a window:
```csharp
ThemeManager.ChangeBaseTheme(Application.Current, baseLightResource, baseDarkResource);
```
The following is a very simple example of usage if you have a custom theme called Gray and the two resource dictionaries were in a folder named ThemeBases in your applications directory and you want to change the theme base for the entire application:
```csharp
private ResourceDictionary grayLightResource;
private ResourceDictionary grayDarkResource;
private ResourceDictionary baseLightResource;
private ResourceDictionary baseDarkResource;

private void LoadThemeBases()
{
var programDirectory = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
if (programDirectory != null)
{
var themeBaseDirectory = programDirectory + @"\ThemeBases";

if (Directory.Exists(themeBaseDirectory))
{
var grayLightPath = Path.Combine(themeBaseDirectory, "GrayLight.xaml");
var grayDarkPath = Path.Combine(themeBaseDirectory, "GrayDark.xaml");

if (File.Exists(grayLightPath) && File.Exists(grayDarkPath))
{
this.grayLightResource = new ResourceDictionary { Source = new Uri(grayLightPath) };
this.grayDarkResource = new ResourceDictionary { Source = new Uri(grayDarkPath) };
}
}
}

baseLightResource = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml") };
baseDarkResource = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml") };
}

private void BaseTheme_Click(object sender, RoutedEventArgs e)
{
ThemeManager.ChangeBaseTheme(Application.Current, baseLightResource, baseDarkResource);
}

private void GrayTheme_Click(object sender, RoutedEventArgs e)
{
ThemeManager.ChangeBaseTheme(Application.Current, grayLightResource, grayDarkResource);
}
```

If you wan to see a test I have created a test branch at https://github.com/Tide/MahApps.Metro/tree/theme-base-test . I added a menu item to the demo to demonstrate.