-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Unable to change the MessageDialog highlighted button #2752
Comments
For now this is what I have come up with, which seems to be working as desired: Create a ResourceDictionary file with the following: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls">
<Style BasedOn="{StaticResource SquareButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
<Setter Property="Background" Value="{StaticResource AccentColorBrush}" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="AccentedDialogSquareButton"
BasedOn="{StaticResource SquareButtonStyle}"
TargetType="{x:Type ButtonBase}">
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
<Setter Property="Background" Value="{StaticResource AccentColorBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary> Then load the resource into the MetroDialogSettings object that is being passed to the ShowMessageAsync method: dialogSettings.CustomResourceDictionary = new ResourceDictionary { Source = new System.Uri("pack://application:,,,/ComponentsProject;component/Themes/Components.MetroMessageBox.xaml") };
var result = await metroWindow.ShowMessageAsync(caption, message, dialogStyle, dialogSettings); @punker76 Might have been better to post this at StackOverflow maybe, unless you still feel this should be something in the base. |
@DavidIQ The style is now set to the selected default button in code behind. Available in 1.4.0 |
Great, thanks @punker76 |
var metroDialogButton = new MetroDialogSettings() |
What steps will reproduce this issue?
Set DefaultButtonFocus to something other than the Affirmative button for MessageDialogSettings and call the MetroWindow's ShowMessageAsync.
Expected outcome
Highlighted button is set to the default button. Why? Because users are under the impression that the highlighted button is what will be selected when they hit the Enter key. This does not seem to be something that can be overridden though:
https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/MahApps.Metro/Themes/Dialogs/MessageDialog.xaml#L35
Other than making the Affirmative button look like the others there doesn't appear that I can do much of anything else to the style to highlight the actual default button.
--
Environment
The text was updated successfully, but these errors were encountered: