2017-03-01 1 views
0

Alors ceci est mon contrôleur:Mahapps TextBox ClearTextButton manquant lorsque le style add

<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> 

Comme vous pouvez le voir, j'ai ajouté Property="Controls:TextBoxHelper.ClearTextButton" Value="True" mais je ne vois pas ce Buttons unlen j'ai enlevé tous Triggers et ajoutez ceci à l'intérieur du contrôleur:

<TextBox 
    Width="398" 
    Height="25" 
    Margin="23,0,0,0" 
    Controls:TextBoxHelper.ClearTextButton="True"> 
</TextBox> 
+0

Cette question est probablement ce que vous cherchez: http://stackoverflow.com/questions/32230427/extending-textbox-in-wpf-using-mahapps- garder-style – petric

Répondre

2

Vous devez baser votre Style sur la "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> 

Ou l'implicite un:

<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}" > 
...