7
我已經開始在我的WPF應用程序中引入MahApps .Metro(真棒),我最喜歡的按鈕是默認的。問題是它把我所有的文本都放在大寫字母中,我不想要它。MahApps - 如何禁用默認按鈕的自動大寫
我已經開始在我的WPF應用程序中引入MahApps .Metro(真棒),我最喜歡的按鈕是默認的。問題是它把我所有的文本都放在大寫字母中,我不想要它。MahApps - 如何禁用默認按鈕的自動大寫
您可以通過設置所有按鈕的財產Window.Resources
<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
設置導致的風格在這個0適用於所有的按鈕。
如果您將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默認行爲,但感謝你的解決方案。奇蹟般有效。 – mababin
您也可以使用「http」mahapps命名空間:'xmlns:controls =「http://metro.mahapps.com/winfx/xaml/controls」'。當然你需要在項目中安裝mahapps軟件包。 – heltonbiker
如何保持一切的原始情況? Shoudn't「正常情況下」是正常情況?! – Leon