Windows Phone开发(25):启动器与选择器之WebBrowserTask
2012-03-28 21:31
375 查看
从名字上就看出来,这个家伙就是打开浏览并浏览到指定页面。
它有两个用途完全一样的属性:Uri属性是System.Uri类型,这是新写进的属性;
URL是字符串类型,但如果使用该属性,会发出警告“已过时”,所以建议使用前者。
下面这个例子,点击按钮后都是打开WEB浏览器并定位到文本框中输入的地址,但分别用了上面所说的两个属性,当程序运行后,你会发现其效果是一样的。
它有两个用途完全一样的属性:Uri属性是System.Uri类型,这是新写进的属性;
URL是字符串类型,但如果使用该属性,会发出警告“已过时”,所以建议使用前者。
下面这个例子,点击按钮后都是打开WEB浏览器并定位到文本框中输入的地址,但分别用了上面所说的两个属性,当程序运行后,你会发现其效果是一样的。
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 转:http://blog.csdn.net/tcjiaan/article/details/7404770
- Windows Phone开发(25):启动器与选择器之WebBrowserTask
- Windows Phone开发(25):启动器与选择器之WebBrowserTask .
- Windows Phone开发(25):启动器与选择器之WebBrowserTask
- Windows Phone开发(26):启动器与选择器之MediaPlayerLauncher和SearchTask 转:http://blog.csdn.net/tcjiaan/article/details/7408968
- Windows Phone开发(22):启动器与选择器之BingMapsDirectionsTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask 转:http://blog.csdn.net/tcjiaan/article/details/7396621
- Windows Phone开发(22):启动器与选择器之BingMapsDirectionsTask .
- Windows Phone开发(22):启动器与选择器之BingMapsDirectionsTask 转:http://blog.csdn.net/tcjiaan/article/details/7393099
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask .
- Windows Phone开发(22):启动器与选择器之BingMapsDirectionsTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(25):启动器与选择器之WebBrowserTask
- Windows Phone开发(22):启动器与选择器之BingMapsDirectionsTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(22):启动器与选择器之BingMapsDirectionsTask
- Windows Phone开发(23):启动器与选择器之CameraCaptureTask和PhotoChooserTask
- Windows Phone开发(24):启动器与选择器之发送短信 转:http://blog.csdn.net/tcjiaan/article/details/7404643