New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for dark theme flat button FocusVisualStyle #3118

Closed
JVimes opened this Issue Dec 9, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@JVimes

JVimes commented Dec 9, 2017

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

@punker76 punker76 added the enhancement label Dec 9, 2017

@punker76 punker76 self-assigned this Dec 9, 2017

@punker76 punker76 added this to the 1.6.0 milestone Dec 9, 2017

punker76 added a commit that referenced this issue Dec 9, 2017

(#3118) Fix for dark theme FlatButton FocusVisualStyle Foreground
  Use `FlatButtonForegroundBrush` in the new `MahApps.Metro.Styles.FlatButtonFocusVisualStyle` and use it for `MetroFlatButton` and `MetroFlatToggleButton`

punker76 added a commit that referenced this issue Dec 9, 2017

Merge pull request #3119 from MahApps/feature/3118_Fix_for_FlatButton…
…_FocusVisualStyle

(#3118) Fix for dark theme FlatButton FocusVisualStyle Foreground

punker76 added a commit that referenced this issue Dec 13, 2017

(#3118) Fix for dark theme FlatButton FocusVisualStyle Foreground
  Use `FlatButtonForegroundBrush` in the new `MahApps.Metro.Styles.FlatButtonFocusVisualStyle` and use it for `MetroFlatButton` and `MetroFlatToggleButton`

punker76 added a commit that referenced this issue Dec 13, 2017

Merge pull request #3119 from MahApps/feature/3118_Fix_for_FlatButton…
…_FocusVisualStyle

(#3118) Fix for dark theme FlatButton FocusVisualStyle Foreground

@punker76 punker76 added Bug and removed Enhancement labels Feb 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment