Microsoft.Win32.OpenFileDialog.ShowDialog()何时返回null? [英] When does Microsoft.Win32.OpenFileDialog.ShowDialog() return null?
问题描述
OpenFileDialog 的 ShowDialog 方法返回可为空的布尔值,如果用户单击确定",或者单击取消",则返回false.什么时候返回null
?该文档没有说.
OpenFileDialog's ShowDialog method returns a nullable boolean, set to true if the user clicked OK or false if he clicked Cancel. When does it return null
? The documentation does not say.
推荐答案
This is stated in the questions linked below, but I'll mention here that Programming WPF (Chris Sells, Ian Griffiths) says:
ShowDialog将始终返回true或 错误的. ...仅在对话结束后 已显示,但在关闭之前 DialogResult为空.
ShowDialog will always return true or false. ... Only after a dialog has been shown but before it's been closed is DialogResult null.
类似的问题:何时ShowDialog()返回null?
并且:为什么DialogResult在WPF中是可为空的布尔值?
这篇关于Microsoft.Win32.OpenFileDialog.ShowDialog()何时返回null?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!