7

I have looked at the documentation at http://mahapps.com/controls/dialogs.html but I am still not sure how to use it. There is no documentation for ShowMetroDialogAsync().

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Kunal Deo
  • 2,248
  • 2
  • 18
  • 27
  • await ShowMetroDialogAsync(MetroWindow, BaseMetroDialog) ? http://www.nudoq.org/#!/Packages/MahApps.Metro/MahApps.Metro/DialogManager/M/ShowMetroDialogAsync – sexta13 Apr 24 '14 at 13:38
  • 1
    I tried that but I am not able to create the instance of BaseMetroDialog. have you tired it ? – Kunal Deo Apr 24 '14 at 13:46
  • BaseMetroDialog is an abstract class. You have to implement your own class. I have not tried... – sexta13 Apr 24 '14 at 13:55
  • 1
    did you find the answer to this? because i m also stuck on this – wingskush Feb 03 '15 at 09:24

2 Answers2

8

You have to create the dialog as a control like this:

<metro:BaseMetroDialog x:Class="Example.Dialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:metro="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
    Title="My new dialog">
  <TextBlock Text="Example" />
</metro:BaseMetroDialog>

Then, from another MetroWindow, you can show the dialog with something like this:

var dialog = new Example.Dialog()
await this.ShowMetroDialogAsync(dialog);
GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Gustavo Cantero
  • 440
  • 6
  • 9
-1

Add the following code:

await DialogManager.ShowMessageAsync(this, "Message Title here", "Your message description here");

The this keyword references your window

msrd0
  • 7,816
  • 9
  • 47
  • 82
Kristof
  • 31
  • 2
  • 3
    The OP asked for `ShowMetroDialogAsync` not `ShowMessageAsync`. The former allows for custom content –  Dec 11 '15 at 01:24