I'm starting out with WPF, and I donβt even know where to look for the answer to this question. This XAML seems very simple to me:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid> <Button> <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="Green"/> </Trigger> </Style.Triggers> </Style> </Button.Style> <Button.Content>Test</Button.Content> </Button> </Grid> </Page>
When I click on the button, IsMouseOver changes to True , and the trigger makes the green background green. For a moment. Then it turns blue.
Even better: if I bind the same installer to the IsFocused property, as soon as I focus on the button, the background color will start between green and blue.
There is something, somewhere in Button (I assume that in any theme it is used by default under Vista), which makes it behave this way. I suspect that there is another property that the trigger should set. But what?
source share