Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 使用Windows.UI.Popups_Visual Studio_C# 4.0 - Fatal编程技术网

Visual studio 使用Windows.UI.Popups

Visual studio 使用Windows.UI.Popups,visual-studio,c#-4.0,Visual Studio,C# 4.0,我正在尝试为学校制作WPF应用程序。它非常简单,只需要将用户名作为输入,当单击ok按钮时,会出现一个对话框,显示Hi(您的姓名)。我以前只做过控制台应用程序,所以我很难理解WPF的内容。我的书要求使用Windows.UI.Popups,然后编写代码MessageDialog msg=newmessagedialog(“Hello”+username.Text);然后放入msg.showancy() 问题是它一直在说UI不是名称空间?我遗漏了什么?我知道这是一个老问题,但可能有人会像我一样碰到它

我正在尝试为学校制作WPF应用程序。它非常简单,只需要将用户名作为输入,当单击ok按钮时,会出现一个对话框,显示Hi(您的姓名)。我以前只做过控制台应用程序,所以我很难理解WPF的内容。我的书要求使用Windows.UI.Popups,然后编写代码MessageDialog msg=newmessagedialog(“Hello”+username.Text);然后放入msg.showancy()


问题是它一直在说UI不是名称空间?我遗漏了什么?

我知道这是一个老问题,但可能有人会像我一样碰到它

出现错误的原因是Windows.UI.Popups是与UWP相关的库,在WPF应用程序中不可用

这是MessageDialog类的Microsoft参考文档

由于您使用的是WPF,因此必须

改编自上页的示例代码:

string message = "You clicked OK.";
string caption = "OK";
_ = MessageBox.Show(message, caption, MessageBoxButtons.YesNo);

您使用的是什么操作系统?您需要Visual Studio 2015和Windows 10才能在桌面应用程序中运行此功能。这就是我正在使用的。最后,我使用了MessageBox.Show,但我仍然想知道如何使用其他方法。在没有看到屏幕的情况下,我无法确定问题出在哪里。我面前没有VS 2015,无法尝试为测试目的创建WPF应用程序。请确保已添加对Windows.winmd程序集的引用。并且您明确表示您的应用程序是为/支持Windows 10设计的。我不确定这是否是新C#应用程序的默认设置。(您已经标记了问题C#4.0,如果您使用VS 2015,这有点奇怪。默认情况下,它使用C#6.0,IIRC。)