c# - 如何在 Windows 10 通用应用程序中显示模态窗口?

标签 c# xaml uwp windows-10

当我在 Windows 10 中使用 Mail universal 应用程序时,当我添加一个帐户(设置->帐户->添加帐户)时,似乎会弹出一个模式窗口来选择一个帐户。我尝试使用 MessageDialog,但我无法将任何自定义内容放入其中。

编辑 :这是屏幕截图 screenshot

有人知道如何实现它或者有一些 api 可以做到吗?

注意:打开此窗口后,您甚至无法最小化/最大化/关闭主窗口。所以,它绝对是一个模态窗口。

最佳答案

我自己还没有使用过它,但我相信您正在寻找 ContentDialog api。

var dialog = new ContentDialog() {
    Title = "Lorem Ipsum",
    MaxWidth = this.ActualWidth // Required for Mobile!
    Content = YourXamlContent
};


dialog.PrimaryButtonText = "OK";
dialog.IsPrimaryButtonEnabled = false;
dialog.PrimaryButtonClick += delegate {
};

var result = await dialog.ShowAsync();

content dialog

对话框的 msdn 指南:link

msdn 内容对话框 API:link

关于c# - 如何在 Windows 10 通用应用程序中显示模态窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31803269/

相关文章:

c# - If Condition inside 开关盒

silverlight - 网格、 View 框和 Canvas

c# - 如何更改 UWP 中的 AppBarButton FontSize?

c# - 通过后面的代码设置时,两种方式绑定(bind)不起作用

java - 是否可以用 Java 调用 .NET Core 应用程序?

c# - 单窗体启动时隐藏

c# - 通过共享主机从 asp.net 网站发送批量电子邮件

wpf - 从右到左动画宽度

c# - 如何使用自定义内容定义 UserControl?

c# - 没有控制台窗口的 AppServiceBridge