I have to use a custom template for a WPF control (a RadioButton) and the control has to have a custom implementation of the Focused effect. Because of that don't use the FocusVisualStyle property but implement the effect inside the control template and I want to use the ControlTemplate's Triggers to enable or disable the effect like that:
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="FocusEffect" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
But the problem is that the default Windows behaviour is that the focus effect is visible only when the keyboard navigation mode is on (the user used the Tab key or pressed the Alt key). If I use only the IsKeyboardFocused property, I have the effect even if the control has been clicked with the mouse which should not be the case.
Which property (properties) do I need to use as a trigger to achieve the default behaviour?
In fact, you can freely design a Style for
FocusVisualStyle. It merely defines a control to be overlayed.A Style to surround the
RadioButton's mark would be like the following.You can create alternative Styles as you wish.
Octagon:
Crosshair: