Why IsMouseOver is recognized as a WPF style trigger and MouseDown isn’t -given that both are valid UIElement properties as seen here-. First trigger works well but second one doesn’t even compile.
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="OpacityMask">
<Setter.Value>
<LinearGradientBrush >
<GradientStop Color="Transparent" Offset="0"/>
<GradientStop Color="Black" Offset="0.5"/>
<GradientStop Color="Transparent" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="MouseDown" Value="true">
<Setter Property="OpacityMask">
<Setter.Value>
<LinearGradientBrush>
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
Well, I guess you are mistaking
MouseDownevent for property. There is noIsMouseDownproperty but there exist similarIsPressedproperty but only for classes inheritingButtonBase. You should just use event in code-behind or write an attached property if you want to keep your code-behind clean.This is how you do it. Create class:
Then in your style:
And of course add namespace in your XAML file (look at the top):