适用于Windows Phone 8.1的Web浏览器任务



我可能听起来像个傻瓜,但这个问题真的没有从我的脑海中消失,你也应该试试。

每当我添加Microsoft时。Phone.dll到用于WebBrowserTask控件的Windows Phone 8.1的新项目,我得到以下错误。

我真的不知道如何解决这个问题。

http://2.bp.blogspot.com/-esfQ3c5cZ80/U2KBD5JRDyI/AAAAAAAAAiQ/HyorukOc_a4/s1600/Screenshot+(6( .png

在以前的版本(Windows Phone 8(中,它是完全正常工作的,但众所周知,WP8.1 SDK中有很多更改,因此,我无法解决此问题。

如果您使用Windows商店应用程序项目(WP8.1/Win8.1(,WebBrowserTask类将被Launcher类取代。

现在您必须使用Launcher类中的LaunchUriAsync方法

一些有用的资源:

Windows Phone 8.1 的新增功能

将您的Windows Phone 8应用程序迁移到Windows运行时XAML应用程序

private async void Button_Click(object sender, RoutedEventArgs e)
{
    string uriToLaunch = @"http://www.bing.com";
    var uri = new Uri(uriToLaunch);
    var success = await Windows.System.Launcher.LaunchUriAsync(uri);              
}

不要忘记使用"async"关键字来Button_Click方法