Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

WPF MessageBox Service

0.00/5 (No votes)
21 Nov 2013 1  
A message box service implementation that is based on WPF.

Introduction 

Februrary, 2017.

I have released a ContentDialogService implementation that also supports mocal dialogs through the same API as mentioned in the project below: Here is the link to the CodeProject article:

https://www.codeproject.com/Articles/1170500/A-ContentDialog-in-a-WPF-Desktop-Application

November, 2013:

I have released a message box service implementation that is based on WPF at: https://github.com/Dirkster99/MsgBox.

 

See feature description and documentation for full details of the first version.

  • API coverage of standard System.Message box as of .NET 4.0
  • Themable WPF MVVM compliant Message Box Service
  • Localized in several languages
  • Display of Exception Summary and Details
  • 3 Icon sets
  • 2 Window Chrome Styles + Metro Dark and Light themes
  • Hyperlink display
  • Escape Key, Alt-F4, Window Close Button (X) interpretation
  • Forced Choice supported in a nice way  with user notification

Background  

The implementation is a spin off from my editor project: https://github.com/Dirkster99/Edi.

Best thing is the exception display - it helps me when running the release version and still trying to find some issues that may not appear in the debug version:

result = Msg.Show(exp, "Unexpected Error",
  MsgBoxButtons.OK, MsgBoxImage.Error, MsgBoxResult.NoDefaultButton,
  "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028",
  "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028",
  "Please click on the link to check if this is a known problem (and report it if not):", null, true); 

Using the code 

The code is rather simple to use (see released demo applications for more details). Start a new WPF application project and reference the MsgBox.DLL. Use, for example, this code:

MsgBoxResult result = Msg.Show("hello world message", "hellow world caption"); 

 

to show a simple message box (see codeplex site for more advanced applications).

Points of Interest 

Other message box service implementations are usually part of a particular framework. So re-using these often does not come without the hassle of having to initialize and use a complex framework when all one wants it to use a message box service. Its sometimes even impossible to use a message box service from a particular framework without having to re-use the complete framework. 

Most frameworks I have seen  do not care about the System.MessageBox API. So, a huge conversion is often required when refactoring for that framework. This is not the case with the MsgBox.

Please let me know if you feel the posted documentation is helpful or if you are missing anything crucial. I would also like to see if anyone finds this useful and does actually use it in their application. Please give me your feedback - the good and the bad - if any - thanks a lot. 

History 

  • 13.11.2013 - Initial posting. 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here