The System.Windows.MessageBox provided by .NET is limited to a very small set of MessageBoxButtons (Yes/No/OK/Cancel) which do not allow for custom Button texts. The System.Windows.Forms.MessageBox also blocks the UI thread, which can be an annoying disadvantage as well.

The MessageBox on Windows Phone has the same disadvantages.

Custom buttons in a MessageBoxe simplify the decision for the user, because they can describe the results of the action:

However you need to do this with a custom control, so for WPF as well as Windows Phone I designed a simple method for asynchronously showing a MessageBox with custom buttons. (The WPF implementation based on this control by Evan Wondrasek)

So let’s bring some sample code.In WPF you can use multiple custom buttons:

And on Windows Phone you’re limited to 2 buttons:

To use CustomMessageBox, you need to get TCD.Controls from NuGet:

And on Windows Phone 7.x you also need async support, which is included in the Microsoft.Bcl.Async package:

Just like the other methods from TCD.Controls, CustomMessageBox also features IntelliSense descriptions (or I’ll add them very soon).

Please feel free to provide feedback and/or report bugs 😉