WPF: Inconsistent FileDialogs on Vista 64-bit.

You might run into this problem:

When you try to make an Open/SaveFileDialog on in a WPF program, you might see that the dialog is displayed with the old graphics:

savefiledialog

*yuk*

This seems to be caused by a detection inconsistency somewhere inside the Microsoft.Win32.

To solve the problem you could manually add a Reference to System.Windows.Forms, and use the System.Windows.Forms.OpenFileDialog or the System.Windows.Forms.SaveFileDialog.

This will display the beautiful Open/SaveFileDialog on Vista 64-bit.

Good luck :)

3 thoughts on “WPF: Inconsistent FileDialogs on Vista 64-bit.

  1. This happens because you’re pulling in the old version of comctl32.dll.

    1) Add a manifest to your EXE that specifies version 6 of comctl32.dll.
    2) Call System.Windows.Forms.Application.EnableVisualStyles. Downside is that you’re now referencing an extra DLL for a circumstantial purpose.
    3) P/Invoke into all the CreateAtx* stuff in Win32 API. (in fact, you can limit the scope of the activation context so that it’s only active for the duration of “ShowDialog”.) This documentation is very confusing though.

    This is not a detection problem in Microsoft.Win32. It’s just a fit-and-finish bug that never got fixed.

    You might also have to make sure you aren’t using a hook procedure (not sure if WPF does this “for you”). If you end up with exactly the dialog above except for correctly themed scrollbars and buttons, then this is what’s happening.

  2. Oops, that comment above should list the 3 options are 3 separate ways to achieve the same result. Not 3 things which must be done together or in sequence.

  3. Pingback: Kristof's Blog :: WPF: Inconsistent FileDialogs on Vista 64-bit. #2

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>