OpenFileDialog.ShowDialog() throws an exception?

前端 未结 1 567
醉梦人生
醉梦人生 2021-01-26 00:22

I am trying to show a dialog from one of my WPF view model commands however when i call ShowDialog() it throws a System.ArgumentException, I was wonder

相关标签:
1条回答
  • 2021-01-26 01:08

    Because ShowDialog() itself returns a Nullable(Of Boolean) and your If statement is expecting a non-Nullable Boolean.

    You'll have to cast the dialog's return value to a Boolean and if it's True retreive the selected file through your dialog's Filename property.

    Example.

    0 讨论(0)
提交回复
热议问题