为什么DialogResult的WPF中为空的布尔? [英] Why is DialogResult a nullable bool in WPF?

查看:108
本文介绍了为什么DialogResult的WPF中为空的布尔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能想到一个很好的解释了一个事实,即一个对话的结果是在WPF中的可空布尔?这一直困惑我。在的WinForms它是一个枚举类型,并且做了很多我更有意义。

Can anyone think of a good explanation for the fact that result of a dialog is a nullable bool in WPF? This has always baffled me. In WinForms it was an enum type and that made a lot more sense to me.

推荐答案

在我看来,这样做是因为在大多数情况下你不需要的广义专业的选项,如重试或忽略。

In my opinion this was done because in most cases you don't need the generalized specialized options like Retry or Ignore.

如果您需要更多的确定/取消,你应该使用某种任务对话框,例如中书面出答案。这样,你不仅限于几个枚举值有人认为前几十年,而DialogResult的只是正/负基本使用,你可以实现自己的属性,它是特定于您的高级需求。因此,只有真/假是需要的,和空指示该窗口没有被关闭,但(没有值已被分配给属性尚未)。

If you need more than OK/Cancel, you are supposed to use some kind of task dialog, e.g. with written-out answers. That way, you're not limited to the few enum values someone thought of some decades ago, and the DialogResult is just positive/negative for basic use and you can implement your own property that is specific to your advanced needs. Therefore only true/false is needed, and null indicating that the window has not been closed yet (no value has been assigned to the property yet).

如果你有一个对话框,不仅仅是一个问题,用户应该回答(如报名表),你通常最好使用确定/取消,这样你就不会需要更多的价值。

If you have a dialog that is more than just a question the user should answer (e.g. an entry form), you're typically better off with OK/Cancel, so you don't need more values.

这篇关于为什么DialogResult的WPF中为空的布尔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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