Changing WPF Theme programmatically.

Oct 13, 2010 at 10:37 PM

I really like the themes (especially WhistlerBlue), but I can't seem to find how to change the theme programmatically.

 

It works just fine when I add a line in the application resources of the App.xaml (like this):

<Application x:Class="ThemeTest1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary Source="BureauBlack.xaml"/>
    </Application.Resources>
</Application>

 

But I would really like to allow the user to be able to change the theme at runtime. How do I manage that?

 

Thanks in advance.

David.