MaterialDesignFlatAccentButton Style has incorrect background hover color
In https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/master/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml the definition for MaterialDesignFlatAccentButton is based on MaterialDesignFlatButton but the only change is to the Foreground color to SecondaryHueMidBrush, so it's still using the IsMouseOver Trigger from the base style:
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryHueMidBrush}" />
<Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueMidBrush}" />
</Trigger>
As you can see, it's setting the background and border brush to PrimaryHueMidBrush but since this is an Accent button style, it should overwrite the base color and instead use SecondaryHueMidBrush.
I can see what's causing the problem, I'm just not sure how to fix it myself, short of copying the entire style and replacing the color in the trigger setter. I'm sure there's a better way to fix it that I just don't know myself.
Incidentally, this button style does not appear anywhere on the Demo app, I suspect if it did this would have been spotted and fixed.
IMO a solution would be to do the following:
- [ ] Create a new attached properties in the
ButtonAssistclass. Something like likeFlatButtonMouseOverBackgroundandFlatButtonMouseOverOpacity - [ ] Default the attached properties in the base style to
{DynamicResource PrimaryHueMidBrushColor}and0.16respectively. - [ ] Remove the hard coded resource
PrimaryHueMidBrushfrom the control template in the base style - [ ] Change the template to use a multi binding (with a new converter) that uses the two attached properties to set the brushes inside of the
IsMouseOvertrigger. - [ ] Update the derived styles to set the attached properties to the appropriate theme brush
Bonus point if there are UI tests to go with it.
@Keboo Instead of attached property we could use a converter like
BrushOpacityConverter to applying the primary or secondary brush as IsMouseOver background. I already created a PR (#2131) for similar issue (#2130). Also, I think we don't need change BorderBrush for MaterialDesignFlatButton
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/d75bac11b6d25ad34c78e416b26727344da8c487/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml#L177-L180