tags:

views:

460

answers:

2

Under System.Windows.Controls I can see a PrintDialog however I can't seem to find a native FileDialog. Do I need to create a reference to System.Windows.Forms or is there another way?

A: 

WPF doesn't have one. You either have to make your own or reference it from the WinForms. This is the same with Save and Open dialogs as well.

Joel
+8  A: 

WPF does have built-in (although not native) file dialogs. Specifically, they are in the slightly unexpected Microsoft.Win32 namespace (although still part of WPF). See the OpenFileDialog and SaveFileDialog classes in particular.

Do however note that these classes are only wrappers around the Win32 functionality, as the parent namespace suggests. It does however mean that you don't need to do any WinForms or Win32 interop, which makes it somewhat nicer to use. Unfortunately, the dialogs are by default style in the "old" Windows theme, and you need a small hack in app.manifest to force it to use the new one.

Noldorin
Would you mind elaborating on what needs to be done with the manifest in order to get the new windows theme version?
Sebastian Gray
@Sebastian: Sure - it's detailed on this blog post: http://www.nbdtech.com/blog/archive/2008/06/16/The-Application-Manifest-Needed-for-XP-and-Vista-Style-File.aspx.
Noldorin