Windows Phone开发之Coding4Fun对话框操作类

本文介绍了一种在Windows Phone应用中实现不同样式消息提示框的方法,包括使用标准MessageBox及Coding4Fun库实现自定义提示框的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

去年把windows phone手机的自带弹出框和Coding4Fun做了一个对比【http://blog.youkuaiyun.com/fengyarongaa/article/details/7077031】。今天就把操作类全部贴出来。

1.自己先下载一个Coding4Fun的dll文件,然后引用到项目里面,你懂的!

下载地址http://coding4fun.codeplex.com/

2.直接上代码。

using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Coding4Fun.Phone; using Coding4Fun.Phone.Controls; //@yr.feng namespace MicroBlogForWP7.Classes.Util { /// <summary> /// 对话框 /// </summary> public class Msg { /// <summary> /// 带有"确定"和"取消"按钮消息提示框。返回值为bool类型 /// </summary> /// <param name="content">提示的信息内容</param> /// <param name="title">提示的标题</param> /// <returns>ture or false</returns> public bool ReturnConfirfMsg(string content, string title) { MessageBoxResult m = MessageBox.Show(content, title, MessageBoxButton.OKCancel); if (m == MessageBoxResult.OK) { return true; } else { return false; } } /// <summary> /// 带有"确定"按钮消息提示框。返回值为bool类型 /// </summary> /// <param name="content">提示的信息内容</param> /// <param name="title">提示的标题</param> /// <returns>ture or false</returns> public bool ReturnConfirfMsgByOk(string content, string title) { MessageBoxResult m = MessageBox.Show(content, title, MessageBoxButton.OK); if (m == MessageBoxResult.OK) { return true; } else { return false; } } /// <summary> /// 带"确定"按钮的消息提示框。不具有返回值 /// </summary> /// <param name="content">提示的信息内容</param> /// <param name="title">提示的标题</param> public void ConfirfMsgForOK(string content, string title) { MessageBox.Show(content, title, MessageBoxButton.OK); } /// <summary> /// 带"确定"和"取消"按钮的消息提示框。不具有返回值 /// </summary> /// <param name="content">提示的信息内容</param> /// <param name="title">提示的标题</param> public void ConfirfMsgForOKCancel(string content, string title) { MessageBox.Show(content, title, MessageBoxButton.OKCancel); } /// <summary> /// 使用Coding4Fun组件的淡入淡出对话框。不具有返回值 /// </summary> /// <param name="content">提示的信息内容</param> /// <param name="title">提示的标题</param> /// <param name="timeout">提示消息的显示过期时间。单位毫秒</param> public void Coding4FunForMsg(string content, string title, int timeout) { SolidColorBrush White = new SolidColorBrush(Colors.White); SolidColorBrush Red = new SolidColorBrush(Colors.Brown); ToastPrompt toast = new ToastPrompt { Background = Red, IsTimerEnabled = true, IsAppBarVisible = true, MillisecondsUntilHidden = timeout, Foreground = White, }; toast.Title = title; toast.Message = content; toast.TextOrientation = System.Windows.Controls.Orientation.Horizontal; toast.Show(); } } }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值