I have defined this kind of style in app.xaml:
<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>
And I'm trying to use it in another xaml -file like this:
<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>
But nothing happens when I mouse over the border.. what could be wrong here?
Its because you have set the Background
in the Border
, this will override the Style
You will have to remove Background="#FF801F1F"
from the Border
xaml
so the Style
can set the 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With