DialogResult with FolderBrowserDialog in WPF

后端 未结 4 1203
滥情空心
滥情空心 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:56

    DialogResult is an enumeration and defines values to indicate the return values of dialogs.

    In your code you should check for DialogResult.OK to init your variable with the path selected in the dialog. DialogResult.OK is returned when the "OK"-Button is pressed in the dialog, otherwise is DialogResult.Cancel returned.

    if (result == DialogResult.OK){
      txtSource.Text = fbd.SelectedPath;
    }
    

提交回复
热议问题