Mahapps.metro: [Question or Bug] ShowMessageAsync Highlight Buttons

Created on 13 Feb 2017  路  3Comments  路  Source: MahApps/MahApps.Metro

The colors of the buttons should be swapped.

What steps will reproduce this issue?

When calling the follwing code:

 MetroDialogSettings dialogSettings = new MetroDialogSettings();

                dialogSettings.CustomResourceDictionary = new ResourceDictionary
                {
                    Source = new Uri("NETworkManager;component/Resources/Styles/MetroDialogStyles.xaml", UriKind.RelativeOrAbsolute)
                };

                await dialogCoordinator.ShowMessageAsync(this, "Error", "Could not resolve host name", MessageDialogStyle.AffirmativeAndNegative,dialogSettings)

MetroDialogStyles.xaml

<Style BasedOn="{StaticResource MetroFlatButton}" TargetType="{x:Type Button}" />

    <Style x:Key="AccentedDialogSquareButton"
           BasedOn="{StaticResource MetroFlatButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource WhiteColorBrush}" />
        <Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
    </Style>

    <Style x:Key="AccentedDialogHighlightedSquareButton"
           BasedOn="{StaticResource MetroFlatButton}"
           TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource WhiteColorBrush}" />
        <Setter Property="Background" Value="{DynamicResource HighlightBrush}" />
    </Style>

It looks like this:

image

Shouldn't be the OK-Button highlighted?

Expected outcome

The "OK" Button should be highlighted...

Repo

https://github.com/BornToBeRoot/NETworkManager

Environment

  • MahApps.Metro __v1.4.3__
  • Windows OS __10__
  • Visual Studio __2015__
  • .NET Framework __4.5/4.6__

Most helpful comment

Try setting the DefaultButtonFocus to MessageDialogResult.Affirmative in the MetroDialogSettings.

All 3 comments

Try setting the DefaultButtonFocus to MessageDialogResult.Affirmative in the MetroDialogSettings.

Like @Deadpikle said. The default value for MetroDialogSettings.DefaultButtonFocus is MessageDialogResult.Negative, see
https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Dialogs/BaseMetroDialog.cs#L394

@Deadpikle @thoemmi Thanks!

This would be great in the documentation馃槂

Edit: It was a bit confusing, because when i use ShowInputAsync the default/highlighted button is set to Affirmative...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghiboz picture ghiboz  路  11Comments

feinstein picture feinstein  路  18Comments

seb30 picture seb30  路  12Comments

webprofusion-chrisc picture webprofusion-chrisc  路  10Comments

StickNitro picture StickNitro  路  11Comments