c# - 通用应用消息框 : "The name ' MessageBox' does not exist in the current context"

标签 c# windows-phone-8.1 win-universal-app

我想使用 MessageBox 来显示我的 WP8.1 应用程序中的下载错误。

我补充说:

using System.Windows;

但是当我输入时:

MessageBox.Show("");

我得到错误:

"The name 'MessageBox' does not exist in the current context"

在对象浏览器中,我发现这样的类应该存在,并且在“项目->添加引用...->程序集->框架”中显示所有程序集都被引用。

我错过了什么吗?还是有另一种方式来显示消息框之类的东西?

最佳答案

对于通用应用程序,新 API 要求您使用 await MessageDialog().ShowAsync()(在 Windows.UI.Popups 中)使其与 Win 8.1 保持一致。

var dialog = new MessageDialog("Your message here");
await dialog.ShowAsync();

关于c# - 通用应用消息框 : "The name ' MessageBox' does not exist in the current context",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22909329/

相关文章:

c# - 在 Windows IOT Core UWP 中获取麦克风的输入电平

c# - Visual Studio 2015 : Unable to create universal application

c# - 尝试在 C# WPF 应用程序中捕获

windows-phone-8 - 在 Windows Phone 8.1 中获取 ANID2

c# - 使用 cookie 的 HttpClient (Windows.Web.Http)

visual-studio - Visual Studio 认为一切都是 TypeScript 资源

c# - 动态添加新的身份验证方案

c# - 在 ASP.NET MVC 中修改样式表属性

c# - 同时从网络上的多台计算机访问托管在一台服务器上的 ASP.net 应用程序

javascript - href onclick 在 Windows Phone cordova 应用程序中不起作用