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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 11:37:38  来源:igfitidea点击:

How to use ShowMetroDialogAsync() using mahapps api

wpfmahapps.metro

提问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 关键字引用您的窗口