开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜