October 7, 2016 Leave a comment
In my last piece (“A Simple Way to Make a WPF Chromeless Window”) I demonstrated how one could easily create a chromeless window using Microsoft’s “Windows Foundation Framework”, more commonly known as WPF. This time around I will show you how to make a customized WPF message box.
The reason for this is that the WPF default message box uses the same chrome that the default WPF window does. As a result, if you are going to develop a custom window you will also have to do the same with your message boxes or the contrasts between the two will not look symmetrical.
And being deficient in the graphic arts like many software engineers I found this out the hard way when my own commercial product was well reviewed except for the interface. Hence, my recent work to refine the interface to something much more aesthetically pleasing.
Limitations With Your Own Message Box We Can Work With
The first thing to realize is that developing your own message box will constrain you to a certain extent as to what you can provide with it as the default WPF message box comes with a number of configurable options that you can select to produce certain results. The only problem is that you cannot change how the default message box is displayed since it is reliant on the Win API.
Essentially, a message box will request a user to do one of two things, read the provided information and move on, or ask a questions, which is in practically all cases a “yes” or “no” question.
Luckily, with the WPF modal dialogue, which is the type of window we will use for our message box, we can easily return a “true” or “false” value allowing us to handle the second scenario noted previously.