6

For some reason, the WPF MessageBox looks worse than the one in WindowsForms. The WPF one doesn't have a visual style.

How can the Windows style be applied to the WPF MessageBox?

WindowsForms

WindowsForms

WPF

WPF

bytecode77
  • 14,163
  • 30
  • 110
  • 141
  • You can change `style of WPF message box`. http://weblogs.asp.net/psheriff/a-wpf-message-box-you-can-style Or http://www.codeproject.com/Tips/619333/All-Purpose-Message-Box-in-WPF – Amol Bavannavar Jan 05 '15 at 04:44
  • I want the default Windows one, like in WindowsForms, not something custom drawn. – bytecode77 Jan 05 '15 at 04:45
  • Looks like the Windows 7 style is used, even though you're clearly under Windows 8.x. This is a bug in WPF. You should report to connect / create a UserVoice request. – Federico Berasategui Jan 05 '15 at 06:05
  • It's Windows classic style, not even Windows 7. And I don't think creating a bug request will help me right now. Are there any fixes, like some sort of style manifests? – bytecode77 Jan 05 '15 at 06:07
  • @bytecode77 You should still report this bug. Otherwise it's never going to get fixed. Looking at the WPF internal code it seems like it's just calling user32.dll internally. I wonder why would the winforms one look any different. – Federico Berasategui Jan 05 '15 at 06:12
  • I managed it using an `app.manifest`. I will answer my question unless nobody else comes up with something else. Still, weird that no one found this bug yet. It's so obvious. – bytecode77 Jan 05 '15 at 06:17
  • I dont think you're the only one: This is exactly the same [here](http://stackoverflow.com/questions/5289328/wpf-messagebox-window-style) – Claudio P Jan 05 '15 at 08:57
  • @bytecode77: it's a common problem, and the manifest usually does the trick. – Erti-Chris Eelmaa Jan 05 '15 at 09:40
  • Seems to be the way to go. I wrote an answer to this below. Thanks for your help! – bytecode77 Jan 05 '15 at 09:46

1 Answers1

9

This issue can be fixed by adding an application manifest (Add -> New Item -> Application Manifest File)

    ...
</trustInfo>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*" />
    </dependentAssembly>
</dependency>

Under "Project Properties", point "Manifest" to the file you just created. This is optional for that the manifest can also just be deployed along with the EXE file.

Note: This manifest can be used for any executable, not only WPF, that needs to be "styled".

bytecode77
  • 14,163
  • 30
  • 110
  • 141