'Border does not change color when mouse over [duplicate]
The Border does not change background color when mouse over.
<Border x:Name="border"
CornerRadius="3"
Margin="5"
Background="PaleGreen">
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="GreenYellow"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
Solution 1:[1]
If you set the Background in the Border it is a local value and takes precedence over the style. Move it into the style by creating a Setter and it will work.
<Border x:Name="border"
CornerRadius="3"
Margin="5">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="PaleGreen"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="GreenYellow"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | thatguy |
