MahApps/MahApps.Metro — pull request #1142 by Tide (2014-03-11 06:11:39+00:00)
Title: Adds code to support changing the light and dark resources of the ThemeManager

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.

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:
```
ThemeManager.ChangeBaseTheme(Application.Current, baseLightResource, baseDarkResource);
```
or the following to change the resources for a window:
```
ThemeManager.ChangeBaseTheme(Application.Current, baseLightResource, baseDarkResource);
```
Note: I have not tested changing the resources for a window.

The following is a very simple example of usage if you have a custom theme called Gray:
```
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(object sender, RoutedEventArgs e)
{
ThemeManager.ChangeBaseTheme(Application.Current, baseLightResource, baseDarkResource);
}

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