Custom image enum for MessageBoxResult
I try to create a custom MessageBoxImage for the build in MessageBoxResult
For the custom MessageBoxImage enumeration, I have:
public enum CustomBoxImage
{
Foo = new BitmapImage(new Uri(@"pack://application:,,,/MySoftware;component/Images/foo.png"))
}
and the MessageBoxResult, I have:
MessageBoxResult mrb = MessageBox.Show(
"This will kill you. Are you sure?",
"Kill you",
MessageBoxButton.YesNo, CustomBoxImage.Foo);
But it gives me this error:
Cannot convert from "...CustomBoxImage" to "System.Windows.MessageBoxImage'
How can I insert a customized image enumeration into MessageBoxResult? Or, is it开发者_开发百科 even possible?
You can't customize the message boxes beyond the given options. If you need a fully customized one, you can use a 3rd party component. You can even make a window look fully like a message box and customize it if you really need to.
You can't change the signature of the Show method but you can create a converter between your enumeration and the MessageBoxImage enumeration.
if you want to use things that is not provide by the MessageBox, you can create your own messagebox.
精彩评论