您的位置:首页 > 其它

windows phone 7 学习笔记------常用小工具(一)

2011-04-21 23:22 323 查看
关注WP 7 好久了,也在网上看牛人写的博客很好,从他们中学到了很多的东西。记录新技术的学习过程,并帮助别人一起学习它。学习的宗旨“一起学习共同进步”;

 

今天写了两个常用的小工具特与大家分享。

 

说明:这个两个小工具都要用到第三方提供的服务。

 

小工具一:手机号归属地查询。

运行结果如下:

 





代码如下:

private void btnQuery_Click(object sender, RoutedEventArgs e)
{

client.getMobileCodeInfoCompleted += new EventHandler<Mobile.getMobileCodeInfoCompletedEventArgs>(client_getMobileCodeInfoCompleted);
progressBar.Visibility = System.Windows.Visibility.Visible;
if (tbPhone.Text != "")
{
client.getMobileCodeInfoAsync(tbPhone.Text, "");
}
else
{
MessageBox.Show("电话号不能为空!", "提示", MessageBoxButton.OK);
}
}

void client_getMobileCodeInfoCompleted(object sender, Mobile.getMobileCodeInfoCompletedEventArgs e)
{

if (e.Error == null)
{
tbDisplayAddress.Text = e.Result;
}
}


小工具二:邮政编码查询。

运行结果如下:

 





代码如下:

void btnQuery_Click(object sender, RoutedEventArgs e)
{
client.getAddressByZipCodeCompleted += new EventHandler<ChinaZip.getAddressByZipCodeCompletedEventArgs>(client_getAddressByZipCodeCompleted);
if (txtPostCode.Text == "")
{
txtAddress.Text = "没有联接数据!";
}
else
{
client.getAddressByZipCodeAsync(txtPostCode.Text, "");
}
}

void client_getAddressByZipCodeCompleted(object sender, ChinaZip.getAddressByZipCodeCompletedEventArgs e)
{

if (e.Error == null)
{
txtAddress.Text = e.Result.Nodes[0].Value.ToString();
}
}


非常简单的两个小程序,代码非常的简单。

程序只用着学习使用,不用作商业应用。

原本想上传代码的,可是SkyDrive上传有问题,以后。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: