在WPF里面如何使用FolderBrowserDialogSystem.Windows.Forms.FolderBrowserDialog fd = new System.Windows.Forms.FolderBrowserDialog();
在WPF里面如何使用FolderBrowserDialogfd.ShowDialog(
this);

上面的代码如果是在WinForm程序里面,是没有问题的。但是如果在WPF里面则编译不通过,错误描述是

The best overloaded method match for 'System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window)' has some invalid arguments。

这是因为WPF的窗口不是继承IWin32Window接口的,继承的是System.Windows.IWindowService接口。如果想在WPF程序里面使用FolderBrowserDialog,可以象下面这么写:

在WPF里面如何使用FolderBrowserDialogprivate class OldWindow : System.Windows.Forms.IWin32Window
);

 

相关文章: