600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > c# uwp html源码 C#UWP使用Microsoft Edge打开Web URL

c# uwp html源码 C#UWP使用Microsoft Edge打开Web URL

时间:2021-05-17 01:16:02

相关推荐

c# uwp html源码 C#UWP使用Microsoft Edge打开Web URL

Process.Start是.NET Framework中使用的传统方法,不能直接在UWP应用程序中使用.要在UWP中使用Microsoft Edge打开Web URI,我们可以使用

Launcher.LaunchUriAsync method.例如:

// The URI to launch

string uriToLaunch = @"";

// Create a Uri object from a URI string

var uri = new Uri(uriToLaunch);

// Launch the URI

async void DefaultLaunch()

{

// Launch the URI

var success = await Windows.System.Launcher.LaunchUriAsync(uri);

if (success)

{

// URI launched

}

else

{

// URI launch failed

}

}

但是,这将使用默认Web浏览器打开URI.要始终使用Microsoft Edge打开它,我们可以将Launcher.LaunchUriAsync(Uri, LauncherOptions) method与指定的LauncherOptions.TargetApplicationPackageFamilyName property一起使用.TargetApplicationPackageFamilyName属性可以指定应该用于启动文件或URI的目标包.对于Microsoft Edge,其软件包系列名称为“Microsoft.MicrosoftEdge_8wekyb3d8bbwe”.以下是一个示例,说明如何使用它.

// The URI to launch

string uriToLaunch = @"";

var uri = new Uri(uriToLaunch);

async void LaunchWithEdge()

{

// Set the option to specify the target package

var options = new Windows.System.LauncherOptions();

options.TargetApplicationPackageFamilyName = "Microsoft.MicrosoftEdge_8wekyb3d8bbwe";

// Launch the URI

var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

if (success)

{

// URI launched

}

else

{

// URI launch failed

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。