从名字上就看出来,这个家伙就是打开浏览并浏览到指定页面。

它有两个用途完全一样的属性:Uri属性是System.Uri类型,这是新写进的属性;

URL是字符串类型,但如果使用该属性,会发出警告“已过时”,所以建议使用前者。

下面这个例子,点击按钮后都是打开WEB浏览器并定位到文本框中输入的地址,但分别用了上面所说的两个属性,当程序运行后,你会发现其效果是一样的。

<phone:PhoneApplicationPage x:Class="WebTask.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"FontFamily="{StaticResource PhoneFontFamilyNormal}"FontSize="{StaticResource PhoneFontSizeNormal}"Foreground="{StaticResource PhoneForegroundBrush}"SupportedOrientations="Portrait" Orientation="Portrait"shell:SystemTray.IsVisible="True"><!--LayoutRoot 是包含所有页面内容的根网格--><Grid x:Name="LayoutRoot" Background="Transparent"><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/></Grid.RowDefinitions><!--TitlePanel 包含应用程序的名称和页标题--><StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"><TextBlock x:Name="ApplicationTitle" Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/><TextBlock x:Name="PageTitle" Text="启动Web浏览器" Margin="9,-7,0,0" FontSize="50"/></StackPanel><!--ContentPanel - 在此处放置其他内容--><Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"><TextBlock Height="40" HorizontalAlignment="Left" Margin="38,57,0,0" Name="textBlock1" Text="请输入URL:" VerticalAlignment="Top" Width="286" FontSize="28"/><TextBox Height="72" HorizontalAlignment="Left" Margin="12,122,0,0" Name="txtUrl" VerticalAlignment="Top" Width="394" /><Button Content="通过Uri对象设置并启动" Height="79" HorizontalAlignment="Left" Margin="12,222,0,0" Name="button1" VerticalAlignment="Top" Width="394" Click="button1_Click" /><Button Content="通过字符串设置并启动" Height="79" HorizontalAlignment="Left" Margin="9,323,0,0" Name="button2" VerticalAlignment="Top" Width="394" Click="button2_Click" /></Grid></Grid></phone:PhoneApplicationPage>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;namespace WebTask
{public partial class MainPage : PhoneApplicationPage{// 构造函数public MainPage(){InitializeComponent();}private void button1_Click(object sender, RoutedEventArgs e){// 通过Uri对象设置WebBrowserTask wt = new WebBrowserTask();wt.Uri = new Uri(txtUrl.Text, UriKind.Absolute);wt.Show();}private void button2_Click(object sender, RoutedEventArgs e){// 通过字符串设置WebBrowserTask wt = new WebBrowserTask();wt.URL = txtUrl.Text;wt.Show();}}
}

Windows Phone开发(25):启动器与选择器之WebBrowserTask相关推荐

  1. Windows Mobile开发应该选择哪种开发语言?

    Windows Mobile开发应该选择哪种开发语言?这个问题曾经被问了很多很多次,特别是打算开始学习Windows Mobile开发的朋友.Native Code or Managed Code? ...

  2. Windows 95 诞生 25 周年

    点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 来源 | oschina.net/news/118168 ...

  3. Windows phone7 开发-Zune software is not launched 【转】

    刚学习Windows Phone7开发,遇到这个配置错误,在此记录一下. 错误提示:Zune软件未安装 Zune software is not installed. Install the late ...

  4. Windows Phone开发(28):隔离存储B 转:http://blog.csdn.net/tcjiaan/article/details/7436959...

    上一节我们聊了目录的操作,这一节我们继续来看看如何读写文件. 首先说一下题外话,许多朋友都在摇摆不定,三心二意,其实这样的学习态度是很不好的,如果你对Windows phone开发有兴趣,如果你真想学 ...

  5. 基础html交代选择器,html 选择器之基础选择器

    我把CSS选择器分开成三部分,第一部分是我们常用的部分,我把他叫做基本选择器:第二部分我把他称作是属性选择器,第三部分我把他称作伪类选择器 一.基础选择器 1. 通配符(*):选中所有的元素 2.元素 ...

  6. WP_支持XP的Windows Phone开发环境搭建:“文字+视频”教程(五)

    下面开始讲解Windows Phone开发环境的搭建,运行起来咱们第一个Windows Phone程序.下面讲三种Windows Phone开发环境的搭建方法:真机环境:微软Windows Phone ...

  7. Windows Mobile 开发常见问题集(转自zsu_darkwind的专栏)

    Windows Mobile 开发常见问题集 1.Q:新建项目的时候选择哪个项目类型才能创建智能设备的应用程序? A:在Visual Studio的新建项目对话框中选择Visual C#或者Visua ...

  8. Kinect for Windows SDK开发入门

    Kinect for Windows SDK开发入门(一):开发环境配置 首先来看一下Kinect设备: 1. Kinect设备 黑色的Kinect设备如下图:基座和感应器之间有一个电动的马达,通过程 ...

  9. windows下php的版本如何选择?

    前言: 在windows 在开发PHP,其实还是占绝大数的,因为其方便.快速,且成本更低,而且由于windows上面的其他与php开发相关的软件更多,所以,我们也基本是在windows在开发好,再更新 ...

最新文章

  1. android IPC 进程间通讯
  2. Active Diretory 全攻略(三)--建立域(2)
  3. mysql 硬负载_为啥单机MySQL又遭遇瓶颈?MySQL主从复制替你解决单机问题
  4. 【知识图谱系列】人工智能经典图谱有哪些?
  5. 提高机器学习质量的想法_如何提高机器学习的数据质量?
  6. 20190814 On Java8 第四章 运算符
  7. 定位日站大法之-社会工程学
  8. 管理学基础 形成性考核一
  9. CSS实现自定义虚线
  10. 第二人生的源码分析(八十)界面语言的选择
  11. cqyz oj | 【训练题】铲雪车问题
  12. 用python计算工资工资_python税后工资计算器
  13. TypeError: only integer tensors of a single element can be converted to an index
  14. XLA编译器用于JIT加速
  15. FSCapture 录制视频没有声音的解决方法
  16. 【资讯】2017年乌镇互联网大会,互联网大佬们齐聚首
  17. 论电子商务平台成功的几个关键点
  18. Spark 内存管理堆内和堆外内存规划_大数据培训
  19. coder,你会设计交易系统吗(实干篇)?
  20. 华为A1路由器虚拟服务器,华为a1路由器怎么设置端口映射规则

热门文章

  1. 线性回归 linear regression
  2. 为什么有三AI从来不追热点,信息越多学的越慢
  3. 山东省能源产业项目动态及未来投资决策建议报告2021版
  4. java四种线程池类型以及可选择的阻塞队列
  5. iOS AVAudioSession 配置(录音完声音变小问题)
  6. linux 定时任务
  7. Golang入门教程(四)变量声明
  8. 弱口令的分析和爆破工具使用
  9. 洛谷——P1548 棋盘问题
  10. JAVA基础-常用的其他类