Windows Phone 7 Coding4Fun的弹出框

    用Windows Phone 7的MessageBox弹出框,总觉得不是很过瘾,最近用了Coding4Fun组件提供了弹出框,感觉挺不错的,很好用,在这里推广一下。Coding4Fun开源组件的下载地址:http://coding4fun.codeplex.com/ ,里面有Demo。里面还有其他的一些控件也挺不错的。

里面有5种不同类型的弹窗

1.ToastPrompt:土司弹出框,类似于土司推送通知一样的显示效果,在屏幕上面出现一条消息,然后再消失。

使用语法

        private void Toast_Click(object sender, RoutedEventArgs e)
{
var toast
= new ToastPrompt {
Title
= "Basic",
Message
= ToastLongMsg,
};
toast.Show();
}

2.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?");
}

 3.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
+= input_Completed;

passwordInput.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);
}

4.InputPrompt:输入弹出框,用于t弹出输入框输入其他的信息。

        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);
}

5.MessagePrompt:消息弹出框,普通的消息弹出框,类似于系统默认的messagebox弹出框。

        private void Message_Click(object sender, RoutedEventArgs e)
{
var messagePrompt
= new MessagePrompt
{
Title
= "Basic Message",
Message
= "I'm a basic message prompt. ",
};
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);
}

 

下面这张图片基本上已经很形象地说明了这个控件的属性的含义了。

Windows Phone 7 Coding4Fun的弹出框_第1张图片

 

 

该弹出框控件支持在弹窗内嵌入XAML文件

把表示XAML控件页面的类赋值到Body属性里面

messagePrompt.Body =new BodyUserControl();

 

 

 

再放点美图出来欣赏一下

Windows Phone 7 Coding4Fun的弹出框_第2张图片

 

最后面还有一篇美文来参考:

http://www.windowsphonegeek.com/articles/Coding4Fun-WP7-Message-Prompt-in-depth

 

你可能感兴趣的:(windows,phone)