How can I apply default Windows style to standard MessageBox in WPF?
For example, when I execute next code:
MessageBox.Show("Hello Stack Overflow!", "Test", MessageBoxButton.OKCancel,
MessageBoxImage.Exclamation);
I'm getting message box:

But in the WinForms everything is OK with style:
MessageBox.Show("Hello Stack Overflow!", "Test", MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation);

Solution :
According to this page, WPF picks up the old styles for some of the controls.
To get rid of it, you have to create a custom app.manifest file (Add -> New item -> Application Manifest File) and paste the following code in it (right after the /trustInfo - Tag ):
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
Then you have to compile your solution with this app.manifest (set it in the project properties -> Application -> Point to the new manifest in "Icons and manifest").
If you start your application now it should look like the WinForms- MessageBox.
source : StackOverFlow
Comments
Post a Comment