首先,我们需要在网络上下载一个Coding4Fun
然后,引用 using Coding4Fun.Phone.Controls.Toolkit;
using Coding4Fun.Phone.Controls;
//第一种:AboutPrompt:说明弹出框,特点是弹出框会在屏幕中间,其他的弹出框是在屏幕的上方。 private void About_Click(object sender, RoutedEventArgs e) { var about = new AboutPrompt(); about.Completed += baseObject_Completed; about.Show("是一款精品手机阅读应用,用户可免费下载和使用。它是一个可随身携带的的电子书店,海量图书可供用户免费下载,向用户提供轻松舒适的阅读体验。随时随地,畅享阅读。"); } void baseObject_Completed(object sender, PopUpEventArgs<object, PopUpResult> e) { if (e.PopUpResult == PopUpResult.Ok) MessageBox.Show("OK!"); else if (e.PopUpResult == PopUpResult.Cancelled) MessageBox.Show("CANCELLED!"); else MessageBox.Show("meh?"); }
//第二种:ToastPrompt:类似于土司推送通知一样的显示效果,在屏幕上面出现一条消息,然后再消失。 public string ToastLongMsg = "123"; private void Toast_Click(object sender, RoutedEventArgs e) { var toast = new ToastPrompt { Title = "Basic", Message = ToastLongMsg, }; toast.Show(); }
//第三种:PasswordInputPrompt:密码输入弹出框,用于输入密码信息。 private void Password_Click(object sender, RoutedEventArgs e) { var passwordInput = new PasswordInputPrompt { Title = "Basic Input", Message = "I'm a basic input prompt", }; passwordInput.Completed += new EventHandler<PopUpEventArgs<string,PopUpResult>>(passwordInput_Completed); passwordInput.Show(); } void passwordInput_Completed(object sender, PopUpEventArgs<string, PopUpResult> e) { if (e.PopUpResult == PopUpResult.Ok) MessageBox.Show("You typed: " + e.Result); else if (e.PopUpResult == PopUpResult.Cancelled) MessageBox.Show("CANCELLED! " + e.Result); else MessageBox.Show("meh? " + e.Result); }
private void Input_Click(object sender, RoutedEventArgs e) { var input = new InputPrompt { Title = "Basic Input", Message = "I'm a basic input prompt", }; input.Completed += input_Completed; input.Show(); } void input_Completed(object sender, PopUpEventArgs<string, PopUpResult> e) { if (e.PopUpResult == PopUpResult.Ok) MessageBox.Show("You typed: " + e.Result); else if (e.PopUpResult == PopUpResult.Cancelled) MessageBox.Show("CANCELLED! " + e.Result); else MessageBox.Show("meh? " + e.Result); }
//第五种:MessagePrompt:消息弹出框,普通的消息弹出框,类似于系统默认的messagebox弹出框。 private void Message_Click(object sender, RoutedEventArgs e) { var messagePrompt = new MessagePrompt { Title = "Basic Message", Message = "I'm a basic message prompt. ", //ActionPopUpButtons }; messagePrompt.Completed += stringObject_Completed; messagePrompt.Show(); } void stringObject_Completed(object sender, PopUpEventArgs<string, PopUpResult> e) { if (e.PopUpResult == PopUpResult.Ok) MessageBox.Show("OK: " + e.Result); else if (e.PopUpResult == PopUpResult.Cancelled) MessageBox.Show("CANCELLED: " + e.Result); else MessageBox.Show("meh?: " + e.Result); }