Reputation: 2442
I am trying to change the background of a button with the IsMouseOver
trigger. I have found many good answers on Stackoverflow but I am having a strange issue that I can't seem to find anyone else having. I have the following style defined
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Red"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Purple"/>
</Trigger>
</Style.Triggers>
</Style>
and using it with a button
<Button Content="Some Button"/>
My problem is that when I mouse over the background changes to Purple but then immediately changes to the standard windows blue color with my mouse still over the button. I expect that the background would stay purple until the mouse is no longer over the button. Does anyone know what could be the issue? Thanks.
Upvotes: 0
Views: 307
Reputation: 3369
The standard template for a Button
uses a ButtonChrome component, which takes care of rendering the button according to the current Windows theme. Unfortunately, the ButtonChrome
is not very customizable (basically it does everything in its OnRender
handler), so it you want to make bigger changes to the appearance of the button, you'll have to write a custom template.
Upvotes: 1