Possible Duplicate:
WPF MessageBox window style
For some reason the MessageBox
that comes with WPF has visual styles disabled and I can't find a way to turne them on, in Windows Forms it was simply a matter of calling Application.EnableVisualStyles()
at the start of your program.
To get an idea of what I'm talking about, here are the two examples:
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.MessageBox.Show(
"Windows Forms Dialog",
"Message Box Test",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Asterisk);
System.Windows.MessageBox.Show(
"WPF Dialog",
"Message Box Test",
System.Windows.MessageBoxButton.OK,
System.Windows.MessageBoxImage.Asterisk);
Calling System.Windows.Forms.Application.EnableVisualStyles()
has no affect for WPF.
The Extended WPF Toolkit has a nice themable implementation, but I'm looking for a way to create message boxes that match the operating system that the user is running on. The EWPFT implementation is fantastic if you want the same style on every operating system.
Don't use MessageBox anymore, P/Invoke TaskDialogIndirect instead - it looks nicer than both of those, and has more options (for example, having arbitrary button text)
精彩评论