我正在开发我的第一个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