繁体   English   中英

C#中WPF应用程序中的DialogResult

[英]DialogResult in WPF Application in C#

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

DialogResult result = MessageBox.show("My Message Question", "My Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

这是我第一次使用WPF表单并且DialogResult似乎不可用。 我用什么来获得相同的效果。

谢谢你的帮助。

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

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

请改用MessageBoxResult 并使用MessageBox类。 但是这个消息框看起来会很丑陋的“经典”风格。

另一种选择是使用Extended WPF工具包

另一个选择是去这里下载CrossTechnologySamples.exe然后查看VistaBridge项目。 我建议你在这里仔细看看,因为你会找到其他对话框的样本(如FileOpen,FileSave等),默认情况下在WPF中不存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM