Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable visual styles in WPF for common dialogs?

When using the wpf elements of my application, everything styles to the operating system, but when I use an OpenDialog or a MessageBox, it renders the older Windows 9X way. Is there an easier way I can do an Application.EnableVisualStyles() equivalent call to make the message boxes and dialogs look the same as the rest of the application?

like image 977
Michael Hedgpeth Avatar asked Apr 22 '09 19:04

Michael Hedgpeth


2 Answers

You need to add a manifest to your assembly. You can do this via Add New Item-->General-->Application Manifest file.

Then add the following somewhere inside the asmv1 tag in the manifest file:

<dependency>
    <dependentAssembly>
        <assemblyIdentity name="Microsoft.Windows.Common-Controls" version="6.0.0.0" type="win32" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
    </dependentAssembly>
</dependency>
like image 96
Botz3000 Avatar answered Nov 11 '22 06:11

Botz3000


This blog post may be worth a look:
Why does the OpenFileDialog in WPF look so “1999” and how can I fix it?

like image 20
Tormod Fjeldskår Avatar answered Nov 11 '22 07:11

Tormod Fjeldskår