This project has moved and is read-only. For the latest updates, please go here.

MessageBox with CheckBox

Sep 2, 2011 at 4:33 PM


I am thinking of using the MessageBox but need to have a checkbox as well (for the "Check this if you don't want to see this message again" scenario). I think I will be able to modify the template to do this but wondered if this was planned at any time soon or if you might be able to offer some tips on the best way to do it.



Sep 2, 2011 at 5:47 PM

This is not a planned feature.  You may be able to extend the MessageBox control by modifying its template with the combination of attached properties.  You could also download the source and add the functionality to it.

Jan 27, 2015 at 11:08 AM
Edited Jan 27, 2015 at 11:11 AM
I need this feature as well, so I've created a derived MessageBox class with a custom template and dependency property. I can display it like so:
var msgbox = new CheckableMessageBox ();
But it shows only the OK button. How can change the MessageBoxButton in this msgbox instance to display another set of buttons (YesNo/OKCancel/etc) ?
Jan 27, 2015 at 1:44 PM

If you look at MessageBox.OnApplyTemplate() method, there is a call to "ChangeVisualState( _button.ToString(), true );".
This will set the VisualState to use (to good sets of buttons).
In XAML, the MessageBoxTemplate contains the VisualStates for each sets of buttons, modifying their visibility to show them according to the current visualState.
The VisalStates are :
Jan 27, 2015 at 2:36 PM
Thanks for the tip BoucherS.

I tried to call ChangeVisualState(...) in my derived class but it doesn't change the buttons (Tried in version 2.2).
What does work is calling InitializeMessageBox(...) instead, in which I can specify the buttons and more things that I also need (parent, defaultresult)!