Source: http://www.bcmeng.com/contentdialog/
In the application development we are essential to use the MessageBox in Windows Phone8 in a message box in Windows The phone8.1 became messagedialog. The use of the method is largely different. However, the function of Messagedialog is too simple to meet our actual needs. In Windows Phone 8.1, Contentdialog appears, Contentdialog can not only select a half-screen or full-screen display, the contents of which can be customized like a XAML page.
Let's look at the code and the actual running effect:
Contentdialog Half Screen:
Private Async voidButton_Click (Objectsender, RoutedEventArgs e)//Half Screen{Contentdialog Dialog=NewContentdialog () {Title="Download updates?",//titleContent ="This update would clean the slate for Iron Mans",//contentFullsizedesired=false,//whether to display full screenPrimarybuttontext ="Yes, clean it",//content of the first buttonSecondarybuttontext ="No, dont!" }; Dialog. Secondarybuttonclick+ = Dialog_secondarybuttonclick;//second button click eventDialog. Primarybuttonclick + =Dialog_primarybuttonclick; Contentdialogresult result=awaitdialog. Showasync (); if(Result = = Contentdialogresult.primary) { }//handles the return of the first button Else if(Result = = Contentdialogresult.secondary) { }//handles the return of the second button } Async voidDialog_primarybuttonclick (contentdialog sender, Contentdialogbuttonclickeventargs args) {await NewMessagedialog ("you have selected the first button"). Showasync (); } Async voidDialog_secondarybuttonclick (contentdialog sender, Contentdialogbuttonclickeventargs args) {await NewMessagedialog ("you have selected a second button"). Showasync (); }
Contentdialog Full Screen:
Private Async voidButton_click_1 (Objectsender, RoutedEventArgs e)//Full Screen{contentdialog Contentdialog=NewContentdialog (); Contentdialog. Title="Programming Little Dream"; Contentdialog. Content="focus on Windows Phone app development"; Contentdialog. Primarybuttontext="likes a"; Contentdialog. Secondarybuttontext="Top One"; Contentdialog. Fullsizedesired=true; awaitContentdialog. Showasync (); }
Contentdialog Custom 1:
<Contentdialog x:class="Contentdialogdemo.contentdialog1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="Using:contentdialogdemo"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"XMLNS:MC="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:ignorable="D"Title="DIALOG TITLE"Primarybuttontext=" Sign In"Secondarybuttontext="Cancel"Primarybuttonclick="Contentdialog_primarybuttonclick"Secondarybuttonclick="Contentdialog_secondarybuttonclick"> <stackpanel verticalalignment="Stretch"Horizontalalignment="Stretch"> <textbox name="Email"Header="Email Address"/> <passwordbox name="Password"Header="Password"/> <checkbox name="Showpassword"Content="Show Password"/> <!--content Body--<textblock name="Body"style="{StaticResource Messagedialogcontentstyle}"textwrapping="Wrap"> <TextBlock.Text>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed Doeiusmod tempor incididunt ut labore et dolore magna Aliqua. </TextBlock.Text> </TextBlock> </StackPanel></ContentDialog>
Call Method:
New // ContentDialog1 is the system comes with the Content dialog box page await contentdialog1.showasync ();
Contentdialog custom 2:
<Contentdialog x:class="contentdialogdemo.contentdialog2"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="Using:contentdialogdemo"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"XMLNS:MC="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:ignorable="D"Title="Little Dream Dictionary"Primarybuttontext="about the"Secondarybuttontext="Praise"Primarybuttonclick="Contentdialog_primarybuttonclick"Secondarybuttonclick="Contentdialog_secondarybuttonclick"<grid > <gridview horizontalalignment="Center"> <gridviewitem margin="5"> <button content="Search Words"Background="#FFC5246D"></Button> </GridViewItem> <gridviewitem margin="5"> <button content="translation"Background="#FFEAC418"Name="Translate"></Button> </GridViewItem> <gridviewitem margin="5"> <button content="New Words"Background="#FFCB32DA"></Button> </GridViewItem> <gridviewitem margin="5"> <button content="about the"Background="#FF58E4B5"></Button> </GridViewItem> </GridView> </Grid></ContentDialog>
The calling method is the same as above, and the result is as follows:
Windows Phone 8.1 development: (Message Popup) powerful Contentdialog