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

MAUI TableView标题无法显示大写字母(仅Windows端)求助

MAUI Windows端TableView标题自动转为小写的解决方法

Windows平台下使用MAUI内置TableView时,设置TableRoot或TableSection的Title属性(如Title="Example Text"),标题会自动显示为全小写,Android平台无此问题。

用户示例代码:

<TableView Intent="Menu"
           HorizontalOptions="Center">
    <TableRoot Title="Example Text">
        <TableSection>
            <TextCell Text="First Example"
                      Detail="Example details"/>
            <TextCell Text="Second Example"
                      Detail="Example details"/>
        </TableSection>
    </TableRoot>
</TableView>

问题原因

Windows端MAUI的TableView默认样式中,TableRootHeader和TableSectionHeader的文本被设置了强制小写的字符转换规则,导致自定义的Title大小写被覆盖。

解决方法

通过自定义Windows平台的样式,取消文本的强制转换:

  1. 打开Platforms/Windows/App.xaml文件,添加以下样式资源:
<Application.Resources>
    <!-- 修复TableRoot标题小写问题 -->
    <Style TargetType="controls:TableRootHeader">
        <Setter Property="Typography.Capitals" Value="Normal"/>
    </Style>
    <!-- 修复TableSection标题小写问题(如果需要) -->
    <Style TargetType="controls:TableSectionHeader">
        <Setter Property="Typography.Capitals" Value="Normal"/>
    </Style>
</Application.Resources>
  1. 如果仅需在单个页面生效,也可以将上述样式添加到页面的Resources节点中。

效果验证

应用样式后,TableView的标题会严格按照Title属性设置的文本显示大小写,不再自动转为小写。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 18:05:17