8

In need to create native looking customized .Net OpenFileDialog in Windows XP and Windows Vista/7. Add new controls to it, etc. Is there any way to customize standard OpenFileDialog in .Net (WPF specifically)? I've looked through the solutions like OpenFileDialogEx, but all that WINAPI hooking stuff is not acceptable for me. Maybe one knows a way to extract native dialogs via Reflection or something? How the native OpenFileDialog in Windows Vista/7 is implemented? Is it written in WPF? Thanks in advance.

Regards, Pavel.

Pavel
  • 81
  • 1
  • 2

3 Answers3

5

Get used to it because that what it takes. OpenFileDialog is not written in WPF, the dialog exists as unmanaged code inside Windows. The managed wrapper uses GetOpenFileName() on legacy versions, the IFileOpenDialog COM interface on current ones. For the latter one, the IFileDialogCustomize interface was designed to customize the dialog.

These interfaces are only easy to use from a C++ program, a classic scourge of shell programming. Having to support XP machines is a considerable headache as well, realistically you are stuck with the legacy dialog through GetOpenFileName(). Which is what that code project does.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
3

There is a wrapper for the OpenFileDialog in the Windows API Code Pack. It gets you around a lot of the difficulty of P/Invoking it yourself. You can use it from WPF, from Windows Forms, whatever.

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
  • The link is dead. Does it still exist somewhere? – I plus plus Apr 20 '17 at 21:53
  • 1
    I don't think so. It was for Windows 7 stuff, and to a lesser extent Windows 8 stuff, and wasn't designed to stick around this long. It moved from one site to another but looks like it didn't move a third time. Some folks have made copies available -- they're not official so use with caution. http://stackoverflow.com/questions/24081665/windows-api-code-pack-where-is-it – Kate Gregory Apr 20 '17 at 22:00
2

You might take a look at this CodeProject link.

It's an interesting way to create just about any file dialog you might want. And the author includes a link to a WPF version as well as the original article written with XP in mind.

user549220
  • 21
  • 1