我正在開發我的第一個WPF應用程序,並決定使用Mahapps.Metro樣式。 我有這樣一個文本框在我的意見之一:Mahapps.Metro TextBox - ClearTextButton自定義樣式
<TextBox x:Name="txtMy" Style="{StaticResource My_TxtBox}"
Controls:TextBoxHelper.Watermark="My..."
Controls:TextBoxHelper.ClearTextButton="True"
Grid.Row="1" Grid.Column="0" />
注:xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
這是我的文本框樣式:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyApp.Resources.Styles">
<Style x:Key="My_TxtBox" BasedOn="{StaticResource {x:Type TextBox}}"
TargetType="{x:Type TextBox}">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="15" />
<Setter Property="Height" Value="40" />
<Setter Property="Margin" Value="4" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#232228" Opacity="0.6" />
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="#1ABC9C" Opacity="0.6" />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
現在,我的問題是:如何能我將自定義樣式添加到ClearTextButton,即,我想要在ClearTextButton被徘徊或按下時更改它的背景顏色?我該怎麼做?
我在問這個,因爲我在互聯網上沒有發現任何類似的東西。
在此先感謝
有什麼建議? – PeMaCN