C# C中WPF应用程序中的DialogResult#

C# C中WPF应用程序中的DialogResult#,c#,wpf,C#,Wpf,我目前正在用C语言开发一个应用程序,使用WPF,我一直只使用WF。通常,如果我想问用户一个问题,而不是自己进行对话,我会使用 DialogResult result = MessageBox.show("My Message Question", "My Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 这是我第一次使用WPF表单,DialogResult似乎不可用。我用什么来获得同样的效果 谢谢你的帮助。改用。并使用该类。但

我目前正在用C语言开发一个应用程序,使用WPF,我一直只使用WF。通常,如果我想问用户一个问题,而不是自己进行对话,我会使用

DialogResult result = MessageBox.show("My Message Question", "My Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
这是我第一次使用WPF表单,DialogResult似乎不可用。我用什么来获得同样的效果

谢谢你的帮助。

改用。并使用该类。但是这个消息框看起来会很难看的“经典”风格

另一个选择是使用


另一个选择是下载CrossTechnologySamples.exe,然后查看VistaBridge项目。我建议您仔细看看这里,因为您会发现WPF中默认不存在的其他对话框(如FileOpen、FileSave等)的其他示例。

以下是在WPF中执行相同操作的方法:

MessageBoxResult result = MessageBox.Show("My Message Question", "My Title", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
    // Do this
}

Microsoft.Win32 OpenFileDialog和SaveFileDialog在WPF中工作得很好…并且是.NET FW.Aaron的一部分,DialogResults在Win32中不存在------------------下面的代码不起作用-------------如果(ofdConfigFile.ShowDialog()!=DialogResult.OK)----我使用的是打开文件对话框相同的东西,只是缩短了:如果(MessageBox.Show)(“我的消息问题”,“我的标题”,MessageBoxButton.YesNo,MessageBoxImage.Question)==MessageBoxResult.Yes){//do this}