Skip to content

Fix for dark theme flat button FocusVisualStyle #3118

@JVimes

Description

@JVimes

For MetroFlatButton and MetroFlatToggleButton in the dark theme, the keyboard focus rectangle is light-on-light, so it's really hard to see. I suggest a fix, below.

Repro in MahApps.Metro.NET45:

image

My suggested fix

I have a fix, as long as you know how to apply this to only the dark theme. To fix the problem, add this to both MetroFlatButton and MetroFlatToggleButton styles in the dark theme only:

<Setter Property="FocusVisualStyle">
    <Setter.Value>
        <Style>
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Stroke="{DynamicResource FlatButtonForegroundBrush}" StrokeThickness="1" StrokeDashArray="1 2" Margin="2,2,2,2" SnapsToDevicePixels="True" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Setter.Value>
</Setter>

image

How I got that: I used XamlWriter to extract the default FocusVisualStyle at runtime, then switched from SystemColors.ControlTextBrushKey to FlatButtonForegroundBrush.

Environment

  • MahApps.Metro v1.6.0-alpha0184
  • Windows OS 10
  • Visual Studio 2017
  • .NET Framework 4.5

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions