将自定义按钮添加到现有的MessageBox中 [英] Add customized buttons to the existing MessageBox

查看:105
本文介绍了将自定义按钮添加到现有的MessageBox中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在WPF中向现有MessageBox添加自定义按钮?除了通常的确定"和取消"按钮外,我还需要再添加3个按钮并处理它们的事件.

How can I add custom buttons to the existing MessageBox in WPF? Apart from the usual Ok and Cancel buttons, I need to add 3 more buttons and also handle their events.

推荐答案

简短的回答:不可能,您需要编写一个新窗口.

Short answer: No it is not possible, you need to write a new window.

长答案:MessageBox类使用Win32 MessageBox(或者可能是MessageBoxEx)函数,该函数不支持扩展消息框.

Long answer: the MessageBox class uses the Win32 MessageBox (or maybe MessageBoxEx) function, this function does not support extending the message box.

可以在打开消息框后对其进行修改,但是:

It is possible to modify the message box after it is opened, but:

  1. 这是很多工作

  1. It is a lot of work

不支持

您必须直接使用Win32进行操作,消息框窗口不是WPF甚至不是WinForms.

you have to do it using Win32 directly, the message box window is not WPF or even WinForms.

总而言之,编写一个带有一个TextBlock,一个Image和5个按钮的窗口比弄乱MessageBox代码的内部实现细节要少.

All in all, it's less work to write a window with one TextBlock, one Image and 5 buttons than to mess around with internal implementation details of the MessageBox code.

这篇关于将自定义按钮添加到现有的MessageBox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆