不能使用的DialogResult [英] Cannot use 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 anMessagebox
'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屋!