Search code examples
wpfmessageboxmahapps.metro

MahApps Metro MessageBox styling with CustomResourceDictionary


Trying to control MahApps messagebox / dialog styling but it doesn't work. I have a custom style that defines a different button, e.g.:

<Style TargetType="{x:Type Button}">
...
</Style>

Then I'm using this when opening the messageBox:

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);

But is has no effect on the buttons in the messagebox / dialog what so ever. Any pointers?


Solution

  • Try to set the x:Key attribute of your Style to AccentedDialogSquareButton:

    <Style x:Key="AccentedDialogSquareButton" TargetType="{x:Type Button}">
        ...
    </Style>