XAML 当系统主题为黑色时,没有背景的元素的主题在maui中无法正确更改

j13ufse2  于 2023-03-06  发布在  其他
关注(0)|答案(1)|浏览(152)

当改变操作系统的主题时,应用程序通常不会显示所有条目。我尝试改变条目的背景,但在iOS上看不到框架,如果它是空的(没有占位符),那么很难找到它。在App.xaml.cs文件中添加Application.Current.UserAppTheme = AppTheme.Light

iOS和Android上均存在此问题。

3xiyfsfu

3xiyfsfu1#

响应系统主题更改一种简单方法是使用AppThemeBinding标记扩展

<Entry BackgroundColor="{AppThemeBinding Light=Green, Dark=Yellow}"/>

或者您可以使用样式:

<Style TargetType="Entry" x:Key="EntryStyle">
    <Setter Property="BackgroundColor"
            Value="{AppThemeBinding Light={StaticResource LightNavigationBarColor}, Dark={StaticResource DarkNavigationBarColor}}" />
</Style>

有关详细信息,请参阅Respond to system theme changes

相关问题