-
Feb 17th, 2014, 01:21 PM
#1
Thread Starter
Frenzied Member
Creating a MessageBox in a Windows 8 Store app - Sample
Hello.
Once I figured out how to create a message box in a Windows 8 Store app, I made myself a new class that allowed me to easily create message boxes using the way I had always done so in all of my WinForm applications. I have attached this class so that others can use it in the hopes that it makes programming a Windows 8 app easier.
Take the attached class file and add it to your solution. CustomMessageBoxClass.vb
Then you can easily create a message box using code from these examples:
Code:
Private Async Sub btnTHREE_Click(sender As Object, e As RoutedEventArgs) Handles btnTHREE.Click
Dim xMsgBox3 As New EnhancedMessageBox("Shall I format and re-install the operating system?", "Start Over", MessageBoxButtons.OkCancel)
Dim xResult3 As DialogResult = Await xMsgBox3.ShowDialog
If xResult3 = DialogResult.OK Then
lblButtonThreeResult.Text = "You have agreed to re-install the OS."
Else
lblButtonThreeResult.Text = "You clicked the Cancel button."
End If
End Sub
Private Async Sub btnFOUR_Click(sender As Object, e As RoutedEventArgs) Handles btnFOUR.Click
Dim xMsgBox4 As New EnhancedMessageBox("Hurry and click the Yes button!", "", MessageBoxButtons.YesNoCancel)
Await xMsgBox4.ShowDialog
End Sub
Note #1: Yes I realize that the new method of creating a message box in much more versatile. This is not meant to stop anyone from using the new method. This is simply an aid to help people like myself who struggle to get some of the basics figured out.
Note #2: I built and tested this on Windows 8.1 using Visual Studio 2013, as a Windows 8 Store app. I have not tested it as code for a Windows Phone 8 app.
~Peter

-
Feb 24th, 2016, 07:44 PM
#2
Re: Creating a MessageBox in a Windows 8 Store app - Sample
I built and tested this on Windows 10 using Visual Studio 2015, as a Universal Windows app running on Lumia 640 XL phone, only message box with two buttons can be shown, if three buttons specified, the message box doesn't appear at all and the code after Await xMsgBox.ShowDialog executed!
-
Feb 27th, 2016, 10:36 AM
#3
Thread Starter
Frenzied Member
Re: Creating a MessageBox in a Windows 8 Store app - Sample
Hi 4x2y.
I tried my revised Windows 10 (UWP) version, and yes, you can only use 2 buttons on Windows 10 Phone. I'm guessing it's a limitation built into the MessageDialog class for mobile devices. Nice job discovering that!
In reality, a message box should just be used as a boolean (ie: do you want to save? yes or no). If you're asking something with 3 answers, you should probably be using a radio button or a list box.
~Peter

-
Feb 27th, 2016, 10:50 AM
#4
Re: Creating a MessageBox in a Windows 8 Store app - Sample
That's debatable... "XYZ has been modified, do you wish to save before exiting?" - yes, no, cancel... then again, I think about all the mobile apps I use, how they work... don't really know that I've ever seen a three option dialog anywhere.
-tg
-
Feb 27th, 2016, 04:17 PM
#5
Re: Creating a MessageBox in a Windows 8 Store app - Sample
I think it is limited to two buttons only for mobile apps because the device's Back button is used to cancel the message box.
-
Feb 27th, 2016, 10:03 PM
#6
Re: Creating a MessageBox in a Windows 8 Store app - Sample
Yeah, I kinda realized that after the fact. ;P
-tg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|