Search code examples
c#.netxamlmaui

.NET Maui: Light Mode does not display TextCell


I want all of my users to have the light theme of .NET Maui (as the dark mode style is not that nice). That's why I added Application.Current.UserAppTheme = AppTheme.Light; to App.xaml.cs to override the AppTheme to the light one. The problem: My TextCells are not getting displayed anymore and the styles of the Entry element are still dark:

enter image description here

enter image description here


Solution

  • As first please try if this approach does helps you

    Android:

    In MainApplication.cs add into constructor

    AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;
    

    iOS:

    Add into Info.plist new key / value

    <key>UIUserInterfaceStyle</key> <!-- For light mode only -->
    <string>Light</string>
    

    NOTE:

    For both platforms works also following In App.xaml.cs (project file, not under Platforms\Windows) add into constructor

    Application.Current.UserAppTheme = AppTheme.Light;
    this.RequestedThemeChanged += (s, e) => { Application.Current.UserAppTheme = AppTheme.Light; };
    

    If you will have still problems, than you might check under Resources\Styles\Styles.xaml what is BackgroundColor, PlaceholderColor for Entry (or any control) when Light mode is activated

    For Windows in App.xml file which is inside of Platforms\Windows subfolder set property RequestedTheme

    <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>