punker76 / MahApps.Metro.SimpleChildWindow

A simple child window for MahApps.Metro
MIT License
374 stars 55 forks source link

(GH-84) Introduce new ClosedBy property with a close reason enumeration #100

Closed punker76 closed 5 years ago

punker76 commented 5 years ago

The new property ClosedBy indicates now which close reason occured.

var childWindow = new CoolChildWindow() { IsModal = true, AllowMove = true, VerticalContentAlignment = VerticalAlignment.Bottom };
await this.ShowChildWindowAsync<CloseReason>(childWindow, RootGrid);
if (childWindow.ClosedBy == CloseReason.Cancel)
{
    await this.ShowMessageAsync("ChildWindow Result", "The dialog was canceled.");
}

It's also possible to grab this directly as the result of the ShowMessageAsync method.

var childWindow = new CoolChildWindow() {IsModal = true, AllowMove = true, VerticalContentAlignment = VerticalAlignment.Bottom};
var result = await this.ShowChildWindowAsync<CloseReason>(childWindow, RootGrid);
if (result == CloseReason.Cancel)
{
    await this.ShowMessageAsync("ChildWindow Result", "The dialog was canceled.");
}

Closes #84 Closes #91