0

I have a Wpf Application where you are supposed to be able to toggle Dark/LightTheme. In the App.xaml I load the LightTheme and some custom templates.

App.xaml

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Themes/LightTheme.xaml"/>
                <ResourceDictionary Source="Templates/Templates.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

Themes/LightTheme.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <SolidColorBrush x:Key="WindowBackgroundColor"  Color="white" />
    
</ResourceDictionary>

Themes/DarkTheme.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <SolidColorBrush x:Key="WindowBackgroundColor"  Color="black" />
    
</ResourceDictionary>

How do I load the DarkTheme.xaml at runtime from c#?

Robiot
  • 98
  • 9

0 Answers0