Welcome to MSDN Blogs Sign in | Join | Help

Lester's WPF blog


Simple, easy & beautiful
Vista style Open/Save FileDialogs

If you have tried creating FileDialogs in WPF, they usually do not blend well into the Vista look.

The solution is to use the wrappers provided in the VistaBridge library which is part of the SDK samples. You could include the library dll (around 100k) in your project and then make the simple call to CommonOpenFileDialog/CommonSaveFileDialog ... The other option being to just include the specific classes in the project.

CommonSaveFileDialog saveDialog = new CommonSaveFileDialog();

Its that easy!!

Share this post
Posted: Monday, May 14, 2007 6:49 PM by llester

Comments

Thomson said:

Could not find the sample or the VistaBridgeLibrary mentioned in this article.

# May 17, 2007 11:29 AM

DamageInc said:

The only problem I see is I will need to build a new version of my project if the VistaBridge library is updated.

# May 17, 2007 1:24 PM

llester said:

Thomson, you can get the sample and library from here

http://msdn2.microsoft.com/en-us/library/ms756482.aspx

DamageInc, your concerns are valid but the calls are standard and are unlikely to change. The other option to using the dll is to use the specific code classes provided in the library

# May 18, 2007 12:39 PM

Dirk said:

Did anyone at Microsoft tried this under Vista x64? Apparently not. When clicking on the buttons in the VistaInteropDemoApp it either crashes or nothing happens. Setting the platform target of the VistaInteropDemoApp to x86 solves the problem.

I really doubt that making "Any CPU" the default target in C# projects was a good decision. I bet a lot of developers do not expect these problems when their application is run under x64.

As soon as you have some interop stuff (COM interop, P/Invoke or C++/CLI with /clr or /clr:pure) in your project/solution there are likely to be problems.

# June 16, 2007 5:25 PM

Karl Shifflett said:

Dirk,

Thank you for your comments on Vista x64.  I spent two hours before I found this site.

Total bummer this was not easy wrapped for WPF...

Karl

# June 30, 2007 4:23 PM

Keeron said:

If you use Orcas (Beta 1 onwards), you can get these dialogs for free. The underlying OpenFileDialog class will determine the OS version and show the correct dialog.

# July 11, 2007 12:11 PM
New Comments to this post are disabled
Page view tracker