Using multiple views with Template10 without always showing the Main Page?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 14:08:44

This works EXCEPT that the Main page is also displayed (along with the DetailPage) with the OpenAsync

I think you mean the Shell.xaml page is also displayed. This is because the currently NavigationService is belonged to the frame that without Shell page inside, the Shell page already created before navigation by CreateRootElement method.

I want to go to a specific page when using protocol activation (using Hamburger template)

To meet your requirements,I'd recommend you not to break the navigation structure in your project, but create a new frame for the special scenario that launched by protocol. For example:

public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
    // TODO: add your long-running task here    
    var protocolArgs = args as ProtocolActivatedEventArgs;
    if (protocolArgs != null && protocolArgs.Uri != null)
    {
        Frame newframe = new Frame();
        newframe.Navigate(typeof(Views.DetailPage));
        Window.Current.Content = newframe; // protocol activation
    }
    else
    {
        await NavigationService.NavigateAsync(typeof(Views.MainPage)); // regular activation
    }
}

There is a complete sample already in the newer code that is being pushed out shortly. Its under source branch v 1.1.3p

https://github.com/Windows-XAML/Template10/tree/version_1.1.13p/Samples/MultipleViews/ViewModels

the most recent release V 1.1.2_vs2017 which is the template update for VS2017 also has the same sample, which the code that you posted is more or less the same under the covers with some tweaks to make it work proper with T10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!