Search code examples
c#xamlthemesmaui

How do I force the light theme for a MAUI Windows application?


I would like to force the theme for a MAUI Windows app, for example for screenshot purposes. The Shell and Application Elements don't support the RequestedTheme property that can be used with WinUI.


Solution

  • You can force the theme by setting the RequestedTheme property in the App.xaml in the Platforms\Windows subfolder in the project:

    <maui:MauiWinUIApplication
        x:Class="NetMaui.WinUI.App"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:maui="using:Microsoft.Maui"
        RequestedTheme="Light"
        xmlns:local="using:NetMaui.WinUI">
    
    </maui:MauiWinUIApplication>