wpf 如何使用 mahapps api 使用 ShowMetroDialogAsync()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23270444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use ShowMetroDialogAsync() using mahapps api
提问by Kunal Deo
I have looked at the documentation at http://mahapps.com/controls/dialogs.htmlbut I am still not sure how to use it. There is no documentation for ShowMetroDialogAsync().
我查看了http://mahaps.com/controls/dialogs.html上的文档,但我仍然不确定如何使用它。ShowMetroDialogAsync() 没有文档。
回答by Gustavo Cantero
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:
然后,从另一个 MetroWindow,您可以使用以下内容显示对话框:
var dialog = new Example.Dialog()
await this.ShowMetroDialogAsync(dialog);
回答by Kristof
Add the following code:
添加以下代码:
await DialogManager.ShowMessageAsync(this, "Message Title here", "Your message description here");
The this keyword references your window
this 关键字引用您的窗口

