Use global SystemParameters.FocusVisualStyleKey insead of per control FocusVisual style

Author: Yoooi0Created Nov 24, 2022Updated Sep 14, 2025
Labelsenhancement

Is your feature request related to a problem? Please describe. A bunch of control styles define a FocusVisual style that is used as a setter value for FocusVisualStyle property and there is no way to customize them other than creating custom styles for each control and setting FocusVisualStyle to your own style.

Most of them are identical: https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/2a38b2c70a5e851bc5b926e0641c1848e719d86b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml#L17-L30

Only OptionMarkFocusVisual seems to have different Margin: https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/2a38b2c70a5e851bc5b926e0641c1848e719d86b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml#L13-L25

I think the FocusVisualStyle should be globally defined with SystemParameters.FocusVisualStyleKey in App.xaml:

xaml
<Style x:Key="{x:Static SystemParameters.FocusVisualStyleKey}" TargetType="Control">
    <Setter Property="Control.Template"> 
        ...
    </Setter>
</Style>

If Margin is all that needs to be changed for some controls then maybe a FocusVisualAssist.Margin could be added to allow those controls to have their own FocusVisualStyle:

xaml
<Style x:Key="OptionMarkFocusVisual" BasedOn="{x:Static SystemParameters.FocusVisualStyleKey}">
    <Setter Property="materialDesign:FocusVisualAssist.Margin" Value="0,0,0,0"/>
</Style>

Source: MaterialDesignInXAML/MaterialDesignInXamlToolkit