DialogResult with FolderBrowserDialog in WPF

后端 未结 4 1201
滥情空心
滥情空心 2021-01-17 18:19

First time I\'m implementing a FolderBrowserDialog in WPF and I\'m not loving it one bit...

Aside from the issues I had figuring out that Windows.Forms wasn\'t refer

4条回答
  •  伪装坚强ぢ
    2021-01-17 18:45

    Late answer here but why not just . .

    private void SelectFolder()
    {
        var dialog = new FolderBrowserDialog();
        var status = dialog.ShowDialog(); // ShowDialog() returns bool? (Nullable bool)
        if (status.Equals(true))
        {
            SelectedFolderPath = dialog.SelectedPath;
        }
    }
    

    You can see the result in debugging session. It returns false when the Cancel button is clicked.

提交回复
热议问题