I’ve been trying several properties but I can’t seem to get the result I want. Currently, this is what’s in my resource dictionary:
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="marker" Property="Fill" Value="Black" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="marker" Property="Fill" Value="Black" />
</Trigger>
Now whenever I click one of my buttons (there is 4), the marker object turns black. I move my mouse elsewhere and it’s still black – so far so good. Now, however, if I click another control on my application, the button loses focus (naturally) and therefore the marker isn’t black anymore!
How can this be prevented? I want the marker to stay black when I click the button and once the button loses focus the marker should still stay black until I click the next button.
It sounds more like you’re looking for the kind of behaviour you’d get from ToggleButton, where the button is “checked” and “unchecked” by successive clicks.
Try swapping out your Button for a ToggleButton and adding a trigger for the IsChecked property rather than the properties you have now.