Select folder dialog WPF

后端 未结 10 703
暗喜
暗喜 2020-11-28 19:32

I develop a WPF4 application and in my app I need to let the user select a folder where the application will store something (files, generated reports etc.).

My requ

10条回答
  •  悲哀的现实
    2020-11-28 20:13

    I wrote about it on my blog a long time ago, WPF's support for common file dialogs is really bad (or at least is was in 3.5 I didn't check in version 4) - but it's easy to work around it.

    You need to add the correct manifest to your application - that will give you a modern style message boxes and folder browser (WinForms FolderBrowserDialog) but not WPF file open/save dialogs, this is described in those 3 posts (if you don't care about the explanation and only want the solution go directly to the 3rd):

    • Why am I Getting Old Style File Dialogs and Message Boxes with WPF
    • Will Setting a Manifest Solve My WPF Message Box Style Problems?
    • The Application Manifest Needed for XP and Vista Style File Dialogs and Message Boxes with WPF

    Fortunately, the open/save dialogs are very thin wrappers around the Win32 API that is easy to call with the right flags to get the Vista/7 style (after setting the manifest)

    • Vista style open and save dialogs with WPF (without using the Vista bridge sample)

提交回复
热议问题