不能使用的DialogResult [英] Cannot use DialogResult

查看:730
本文介绍了不能使用的DialogResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用的DialogResult 来检查消息框 YesNoCancel 的。我用下面的代码,我看不出任何问题:

 的DialogResult dlgResult = MessageBox.Show(
关闭之前保存更改?,
警告,
MessageBoxButton.YesNoCancel,
MessageBoxImage.Question);



不过的的Visual Studio 的抛出我的错误说




System.Windows.Window.DialogResult'
是财产,但使用像



解决方案

有一个冲突这里的的DialogResult枚举和的 Window.DialogResult物业



要解决这个问题,你可以使用enumuration的全名。如下所示:

  System.Windows.Forms.DialogResult dlgResult = ... 

不过,由于您使用的 WPF 的,使用的 MessageBoxResult枚举得到消息的结果是:

  MessageBoxResult结果= 
MessageBox.Show(你想看到简单的版本?,
的MessageBox示例,MessageBoxButton.OKCancel);


I tried to use DialogResult to check an Messagebox's YesNoCancel. I'm using the following code which I don't see any problem with:

DialogResult dlgResult = MessageBox.Show(
   "Save changes before closing?", 
   "Warning", 
   MessageBoxButton.YesNoCancel, 
   MessageBoxImage.Question);

But Visual Studio throws me error saying

'System.Windows.Window.DialogResult' is a 'property' but is used like a 'type'

解决方案

There is a confliction here between the DialogResult Enumeration and the Window.DialogResult Property.

To solve this problem, you can use the fully qualified name of the enumuration. As the following:

System.Windows.Forms.DialogResult dlgResult = ...

However, since you are using WPF, use MessageBoxResult Enumeration to get the result of the message:

MessageBoxResult result = 
    MessageBox.Show("Would you like to see the simple version?", 
    "MessageBox Example", MessageBoxButton.OKCancel);

这篇关于不能使用的DialogResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆