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.).
Ability to see the standard folder tree
Ability to select a folder
WPF look & feel, this dialog must look like part of a modern application designed for Windows Vista/7 and not Windows 2000 or even Win9x.
As I understand, until 2010 (.Net 4.0) there won’t be a standard folder dialog, but maybe there are some changes in version 4.0?
Or all what rest to do is use old-school WinForms dialog? If it’s the only way to do what I need, how can I make it closer to Vista/7 style and not Win9x?
On some forums, I saw the implementation of such dialogs but with old ugly icons à la Windows 95. It really doesn’t look nice.
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)