当从WinForms应用程序启动UWP时,后退箭头不起作用

时间:2016-02-17 23:09:45

标签: winrt-xaml win-universal-app template10

所以我们正在整合旧的和新的。 我正在WinForms应用程序中启动我的UWP应用程序。 当我浏览UWP应用程序时,后退按钮不起作用。通常在启动UWP应用程序时一切正常。

这是我的winforms启动代码:

Uri uri = new Uri($"companies:"); 
//see declarations in package.appxmanifest in winten app.
string targetPackageFamilyName = "81e1fc62-68df-45f5-ac35-c86d1277e2db_2zt4j53vqbz02"; 

// see added protocol declaration in package.appxmanifest in win10 app
var supportStatus = await Launcher.QueryUriSupportAsync(
    uri,
    LaunchQuerySupportType.Uri,
    targetPackageFamilyName);

if (supportStatus != LaunchQuerySupportStatus.Available)
{
    var msg = "Can't launch because the app we need is " + supportStatus.ToString();
}
else
{
    var options = new LauncherOptions { TargetApplicationPackageFamilyName = targetPackageFamilyName };
    var success = await Launcher.LaunchUriAsync(uri, options);
}

这是接收代码

public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
    if (args.Kind == ActivationKind.Protocol)
    {
        ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;

        switch (eventArgs.Uri.Scheme)
        {
            case "companies":
                NavigationService.Navigate(typeof(Views.CompaniesPage));
                break;
            case "company":
                NavigationService.Navigate(typeof(Views.CompanyEditPage), eventArgs.Uri.Query);
                break;
            case "query":
                NavigationService.Navigate(typeof(Views.QueryPage));
                break;
            default:
                break;
        }
    }
    else
    {
        NavigationService.Navigate(typeof(Views.CompaniesPage));
        await Task.Yield();

    }
}

0 个答案:

没有答案