Prism: Shell /Different Frame for Navigation UWP

Created on 8 Jan 2017  路  3Comments  路  Source: PrismLibrary/Prism

Problem

I need to create a shell for my application that does not change which contains the frame that should be used to change the apps content. I tried this (code is below), but get a NullReferenceException because of the call order.

Is there an easy way to archive this ?

sealed partial class App : PrismUnityApplication
{
        protected override UIElement CreateShell(Frame rootFrame)
        {
            return new Views.ShellView();
        }

        protected override INavigationService CreateNavigationService(IFrameFacade rootFrame, ISessionStateService sessionStateService)
        {
            var frame = (Shell as Views.ShellView).ContentFrame;
            var adapter = new FrameFacadeAdapter(frame, EventAggregator);
            var navigationService = OnCreateNavigationService(adapter) ?? new FrameNavigationService(adapter, GetPageType, sessionStateService);
            return navigationService;
        }
        ....
}
UWP

Most helpful comment

Maybe this can help you

In App.xaml.cs

protected override UIElement CreateShell(Frame rootFrame)
    {
        var shell = Container.Resolve<AppShell>();
        shell.SetContentFrame(rootFrame);
        return shell;
    }

In AppShel.xaml.cs

    public void SetContentFrame(Frame frame)
    {
        RootSplitView.Content = frame;
    }

In AppShell.xaml

<SplitView x:Name="RootSplitView">
    <SplitView.Content>
        <Frame x:Name="ContentFrame" />
    </SplitView.Content>
</SplitView>

All 3 comments

Maybe this can help you

In App.xaml.cs

protected override UIElement CreateShell(Frame rootFrame)
    {
        var shell = Container.Resolve<AppShell>();
        shell.SetContentFrame(rootFrame);
        return shell;
    }

In AppShel.xaml.cs

    public void SetContentFrame(Frame frame)
    {
        RootSplitView.Content = frame;
    }

In AppShell.xaml

<SplitView x:Name="RootSplitView">
    <SplitView.Content>
        <Frame x:Name="ContentFrame" />
    </SplitView.Content>
</SplitView>

image

works as described above. Thanks

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings