2013-03-05 14 views
6

ho definito questo tipo di stile in app.xaml:WPF Border IsMouseOver grilletto non funziona

<Style x:Key="RedCloseButton" TargetType="Border"> 
      <Style.Triggers> 
       <Trigger Property="IsMouseOver" Value="True"> 
        <Setter Property="Border.Background" Value="Yellow" /> 
       </Trigger> 
       <Trigger Property="IsMouseOver" Value="False"> 
        <Setter Property="Border.Background" Value="Black" /> 
       </Trigger> 
      </Style.Triggers> 
    </Style> 

E io sto cercando di utilizzarlo in un altro -file XAML come questo:

<Border Style="{StaticResource RedCloseButton}" Name="ClearValue" BorderThickness="2" BorderBrush="black" CornerRadius="0,4,4,0" Margin="110,90,0,80" Background="#FF801F1F">     
      <Rectangle Margin="10,11,6,10" Fill="White" RadiusX="2" RadiusY="2" IsHitTestVisible="False"></Rectangle> 
    </Border> 

Ma non succede niente quando passo il mouse oltre il confine .. cosa potrebbe esserci di sbagliato qui?

risposta

13

suo perché è stata impostata la Background nel Border, questo avrà la precedenza il Style

Si dovrà rimuovere Background="#FF801F1F" dal Borderxaml in modo che il Style possibile impostare il Background

<Border Style="{StaticResource RedCloseButton}" Name="ClearValue" BorderThickness="2" BorderBrush="black" CornerRadius="0,4,4,0" Margin="110,90,0,80">     
     <Rectangle Margin="10,11,6,10" Fill="White" RadiusX="2" RadiusY="2" IsHitTestVisible="False"></Rectangle> 
</Border>  
+0

Sì, ha fatto la magia !! Molte grazie! – Jaska

Problemi correlati