Wpf MahApps-如何禁用默认按钮的自动大写
我已经开始在我的WPF应用程序中引入MahApps.Metro(非常棒),我最喜欢的按钮是默认按钮。问题是它将我的所有文本都用大写,我不想要它。您可以通过在Wpf MahApps-如何禁用默认按钮的自动大写,wpf,mahapps.metro,Wpf,Mahapps.metro,我已经开始在我的WPF应用程序中引入MahApps.Metro(非常棒),我最喜欢的按钮是默认按钮。问题是它将我的所有文本都用大写,我不想要它。您可以通过在窗口中设置所有按钮的属性来覆盖默认值。参考资料 <controls:MetroWindow ... xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns="http://schemas.micr
窗口中设置所有按钮的属性来覆盖默认值。参考资料
<controls:MetroWindow
...
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Resources>
<ResourceDictionary>
<Style TargetType="{x:Type Button}"
BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="controls:ButtonHelper.PreserveTextCase" Value="True"/>
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid>
<!-- This would have normally made the text uppercase if not for the style override -->
<Button Content="Button"/>
</Grid>
</controls:MetroWindow>
省略
x:Key
设置会导致样式应用于此MetroWindow
中的所有按钮。如果将ImaBrokeDude的答案应用于App.xaml,则该样式适用于项目任何窗口中的所有按钮
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro">
<Application.Resources>
<ResourceDictionary>
<Style TargetType="{x:Type Button}"
BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="controls:ButtonHelper.PreserveTextCase" Value="True"/>
</Style>
</ResourceDictionary>
</Application.Resources>
我觉得大写字母不应该是MahApps.Metro的默认行为,但感谢您提供的解决方案。工作起来很有魅力。您也可以使用“http”mahapps命名空间:
xmlns:controls=”http://metro.mahapps.com/winfx/xaml/controls“
。当然,您需要在项目中安装mahapps软件包。如何保留所有内容的原始案例?“正常情况”不应该是正常情况吗?!我觉得设计师的设计很不错。但在运行时,按钮样式又回到了默认的WPF样式。