如何使用XAML在默认浏览器中打开URL(Windows-8 Application)

MỀm*_* Ha 2 .net c# url windows-8

如何使用XAML在默认浏览器中打开URL(Windows-8 Application)

使用时:

Process.Start("http://www.google.com/"); 
Run Code Online (Sandbox Code Playgroud)

错误类型或名称空间名称“ Process”在名称空间“ System.Diagnostics”中不存在(您是否缺少程序集引用?)

key*_*rdP 5

您可以使用Launcher.LaunchUriAsync方法。

private async void LaunchSite(string siteAddress)
{
    try
    {
        Uri uri = new Uri(siteAddress);
        var launched = await Windows.System.Launcher.LaunchUriAsync(uri);
    }
    catch (Exception ex)
    {
        //handle the exception
    }
}
Run Code Online (Sandbox Code Playgroud)