XAML .NET Maui:Light模式不显示TextCell

acruukt9  于 12个月前  发布在  .NET
关注(0)|答案(1)|浏览(123)

我希望我所有的用户都有.NET Maui的浅色主题(因为深色模式风格不是那么好)。这就是为什么我将Application.Current.UserAppTheme = AppTheme.Light;添加到App.xaml.cs中,以覆盖AppTheme到light主题。问题是:我的TextCells不再显示,Entry元素的样式仍然是暗的:

tpxzln5u

tpxzln5u1#

首先,请尝试这种方法是否对您有帮助

安卓系统:
在MainApplication.cs中添加到构造函数中

AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;

iOS操作系统:
在Info.plist中添加新键/值

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

注意事项:
对于这两个平台,也可以按照以下步骤在App.xaml.cs(项目文件不是Platforms\Windows下的)中添加到构造函数中

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

如果你仍然有问题,那么你可以在Resources\Styles\Styles.xaml下检查什么是BackgroundColor,PlaceholderColor for Entry(或任何控件)当Light模式激活时

对于Windows,在Platforms\Windows子文件夹中的App.xml文件中设置属性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>

相关问题