Show a dialog with MahApp MetroWindow theme

WPF

The default way of showing a message in a MetroWindow is by running:

this.ShowMessageAsync

However, one the things that makes it unusable is that you cannot change the default width of the dialog, so the only option is to create a custom dialog like this:

\

<Controls:CustomDialog
    x:Class="MyNamespace.CustomDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    Title="Custom Dialog"
    Width="300" // set the width of the dialog to 300 pixels
    Height="200">

    <Grid>
        ... // add any content you want to include in the dialog here
    </Grid>
</Controls:CustomDialog>

...

var dialog = new CustomDialog();
await this.ShowMetroDialogAsync(dialog);

Post a Comment

Previous Post Next Post