所以这是我的控制器:
<TextBox
Width="398"
Height="25"
Margin="23,0,0,0"
>
<TextBox.Style>
<Style TargetType="{x:Type TextBox}" >
<Setter Property="Foreground" Value="Gainsboro"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Controls:TextBoxHelper.ClearTextButton" Value="True"/>
<Setter Property="Padding" Value="0,1,0,0" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Controls:TextBoxHelper.ClearTextButton" Value="True"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
正如您所看到的,我添加了Property="Controls:TextBoxHelper.ClearTextButton" Value="True"
,但我仍然看不到这个Buttons
unlen我删除了所有Triggers
并将其添加到控制器中:
<TextBox
Width="398"
Height="25"
Margin="23,0,0,0"
Controls:TextBoxHelper.ClearTextButton="True">
</TextBox>
答案 0 :(得分:3)
您应将Style
作为“MetroTextBox”Style
的基础:
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}" >
<Setter Property="Foreground" Value="Gainsboro"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Controls:TextBoxHelper.ClearTextButton" Value="True"/>
<Setter Property="Padding" Value="0,1,0,0" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Controls:TextBoxHelper.ClearTextButton" Value="True"/>
</Trigger>
</Style.Triggers>
</Style>
或隐含的:
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}" >
...