For those of you that have used the Input Prompt or rather not have to use a third party reference to make a pop up alert, I have just the project for today’s lesson for you. Let’s say you would like to create an Alert window in which you have to encapsulate a number of additional controls, well you can.

Before we get carried away, let’s go ahead and jump right in and see what we can come up with. Let’s create a new project for this example. Once done so we are ready to get our hands dirty.

In the ContentPanel section in our XAML file, we can go ahead and add a Rectangle control, which we will use as a container for our controls. Be sure to name the control as well as set the Visibility to Collapsed. We will then add a Border control to add a bit of styling and set the Alignment to Center.

What we will do now is add a Grid control inside of our Border control, which we can place additional controls in. We will have two rows and two columns.

In the (0,0) location of our Grid control we will now go ahead and place a StackPanel control. Inside this StackPanel we will be using this to organize our Radio Button controls that we will be using for this to demonstrate the versatility and amount of controls that can be used within our DIY Alert.

Once we have that taken care of we can move to the (1,0) and (1,1) locations in which we will be placing a Button control in each for Confirmation or to Cancel, respectively. We will also add the Click events for these two Buttons as well.

And this will be all we have in our Alert. To Initiate the Alert we will be using a Button control in our Main Content Grid and create a Click event as well.

Moving along to our Code Behind we will now be taking care of our OnClick events for our three Button controls; two in the Alert and one in our Main Content.

For our Main Content Button we will be setting the Rectangle control, as well as our Border control Visibility equal to Visible.

For our Cancel Button control we will be returning our Border and Rectangle controls back to their Visibility equal to Collapsed.

Last but not least, on our Confirmation Button control we will be displaying a simple MessageBox with some text to display to visualize that the event has taken place. But we are not done. This will not collapse our Alert, so what we can do instead of repeating the same code we wrote for our Cancel event is call the Cancel OnClick event.

And there you have it, a simple Alert Window without the need for third party references or toolkits, and the ability to customize it to your very own liking. If you have any other questions or concerns and have not yet downloaded the source code for this project, I strongly suggest doing so. Seeing it in its entirety can help clear up many of your questions. Thank you for your time and I hope this has been helpful, take care.

Download Source Files