c# - 将按钮内容设置为大写

标签 c# wpf wpf-controls

我有一个特定的按钮内容,其中 Tx 是一个 UTExtension,用于通过按键获取字符串。如何将字符串转换为大写。

<Button
     Style="{StaticResource ButtonHomePageLeft}"
     Content="{Tx:UT Key=Tx:homepage.button.info}"/>

我尝试了这种方式,但它抛出异常

<Button
     Style="{StaticResource ButtonHomePageLeft}"
     Content="{Bindin Path={Tx:UT Key=Tx:homepage.button.info},
                      Converter={StaticResource ToUpperCaseConverter}}"/>

抱歉,我的问题不够具体。即使我以这种方式使用代码,我也会遇到异常。

 <Button
    Style="{StaticResource ButtonHomePageRight}">
    <Button.Content>
          <Binding>
               <Binding.Path>
                    <Tx:UT Key="Tx:homepage.button.use"/>
               </Binding.Path>
          </Binding>
    </Button.Content>
 </Button>

以及我得到的错误。 enter image description here

最佳答案

您可以尝试 Button 的 Typography.Capitals 属性:

<Button Typography.Capitals="AllSmallCaps"></Button>

关于c# - 将按钮内容设置为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36175077/

相关文章:

c# - 属性总是不可变的吗?

C# 发现使用 var 关键字声明的变量的隐式类型

c# - 如何在 C# 中插入新行时从存储过程获取 autoID

wpf - 删除 ContextMenu 上的图标空间

c# - Decimal.GetHashCode 取决于尾随零

wpf - 仅在发生外部事件时更改 ToggleButton/RadioButton 状态

wpf - 将 ContextMenu 的 MenuItem 可见性绑定(bind)到 ListView 选择

.net - 如何设置和更改 WPF 中的文化

wpf-controls - WPF - 向动态添加的 Tabitem 添加动态控件?

c# - 如何在聚焦时删除 WPF 控件周围的虚线