You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MAUI中UserAppTheme设置无法应用于Picker/SearchBar的问题

MAUI手动切换主题后Picker与SearchBar显示异常问题

环境

  • VS 17.4 Preview 1
  • Windows 10
  • 系统主题:深色

复现步骤

  1. 创建新的MAUI项目
  2. 在App.xaml.cs文件中添加代码,强制设置应用为浅色主题:
Application.Current.UserAppTheme = AppTheme.Light;
  1. 在MainPage.xaml中添加包含Picker和SearchBar的布局:
<StackLayout>
    <Border Stroke="Red">
        <Picker>
            <Picker.ItemsSource>
                <x:Array Type="{x:Type x:String}">
                    <x:String>Item1</x:String>
                    <x:String>Item2</x:String>
                    <x:String>Item3</x:String>
                </x:Array>
            </Picker.ItemsSource>
        </Picker>
    </Border>
    <Border Stroke="Blue">
        <SearchBar WidthRequest="300"
                   HeightRequest="50"
                   Placeholder="input search text"
                   TextColor="Blue" />
    </Border>
</StackLayout>
  1. 确认系统当前处于深色主题
  2. 启动应用程序

异常现象

  • Picker的下拉面板仍保持深色样式,未跟随应用切换为浅色主题
  • Picker鼠标悬停时文本变为白色,与浅色背景冲突,视觉上看似消失
  • SearchBar的操作按钮颜色为白色,在浅色主题背景下无法看清

内容的提问来源于stack exchange,提问作者ss1969

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 15:05:21