C# - WPF - 在不使用 System.Windows.Forms 的情况下获取文件夹浏览器对话框?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16304523/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:42:28  来源:igfitidea点击:

C# - WPF - getting folder browser dialog without using System.Windows.Forms?

c#.netwpffolderbrowserdialog

提问by Ms. Nobody

I have this WPFapp and I want to have there function of getting a directory path from the user. I would like to use some folder browser dialog but I don'twant to implement it from System.Windows.Formsor use some huge script inside. Is there some path getting dialog in WPF already implemented?

我有这个WPF应用程序,我希望有从用户那里获取目录路径的功能。我想用一些文件夹浏览器对话框,但我希望从实现它System.Windows.Forms,或者使用一些巨大的脚本中。WPF中是否有一些路径获取对话框已经实现?

I have read answers to similar questions here but it was full of System.Windows.Forms..

我在这里阅读了类似问题的答案,但它充满了 System.Windows.Forms..

I haven't found anything like that in the Toolbox and I'm starting with WPF so I could use some help.

我在工具箱中没有找到类似的东西,我从 WPF 开始,所以我可以使用一些帮助。

Thank you in advance :]

先感谢您 :]

回答by Bernhard Krenz

we use Ookii Dialogsin our projects. They have the windows-look and feel and the typical options for filtering etc.

我们在我们的项目中使用Ookii Dialogs。它们具有 Windows 的外观和感觉以及用于过滤等的典型选项。

回答by Vladimir Petrov

There are no standard native WPF dialogs for what you are looking for, simply because the System.Windows.Forms dialogs are nothing more than wrappers to the system ones. So creating a WPF wrapper makes no sense and will only add to the confusion.

对于您要查找的内容,没有标准的本机 WPF 对话框,因为 System.Windows.Forms 对话框只不过是系统对话框的包装器。因此,创建 WPF 包装器毫无意义,只会增加混乱。

回答by T Powers

See my answer to Select folder dialog WPF. Basically the Windows Presentation Foundation 4.5 Cookbookrecommends that you use the Windows? API Code Pack for Microsoft? .NET Frameworkif you need a folder browser.

请参阅我对选择文件夹对话框 WPF 的回答。基本上Windows Presentation Foundation 4.5 Cookbook建议您使用Windows?适用于 Microsoft 的 API 代码包?如果您需要文件夹浏览器,请使用.NET Framework

回答by C. Augusto Proiete

The Ookii Dialogs for WPFlibrary has a VistaFolderBrowserDialogclass that provides a complete implementation of a folder browser dialog for WPF.

Ookii对话框进行WPF库有一个VistaFolderBrowserDialog类,可以为WPF的文件夹浏览器对话框的完整实现。

https://github.com/augustoproiete/ookii-dialogs-wpf

https://github.com/augustoproiete/ookii-dialogs-wpf

enter image description here

enter image description here

There's also a version compatible with Windows Formsapps

还有一个与Windows 窗体应用程序兼容的版本