Scott Bamforth
Scott Bamforth

Reputation: 148

Universal Windows App layout page

I'm starting a new universal windows app project. Normally I do web developer but have been asked to do a Universal Windows Application.

I'm starting to get somewhere now and have been using MVVM Light and have a couple of views set up.

Anyway here is my question, is there a way for me to have a "Layout" page, similar to what I would have it ASP.NET MVC?

For example, I have the main xaml page in my app, and the root control in that page is a SplitView. I have it so that when I click a button in the split view pane it takes me to the correct xaml view for that button. The thing is this page doesn't have the split view so I no longer have any navigation.

Surely I don't need to duplicate my menu across every view? I assume I'm missing something blindingly obvious.

Thanks,

Upvotes: 1

Views: 157

Answers (2)

M. Pipal
M. Pipal

Reputation: 734

I think you need something like this. You have to navigate your pages just to frame in SplitView content, not to default application's frame.

<SplitView>
    <SplitView.Pane>
        Your menu
    </SplitView.Pane>
    <SplitView.Content>
        <Frame Name="ContentFrame" />
    </SplitView.Content>
</SplitView>

And than in code-behind set the page you want like default

public MainPage()
{ 
    this.InitializeComponent();
    ContentFrame.Navigate(typeof(Homepage));
}

Upvotes: 0

GeertvdC
GeertvdC

Reputation: 2918

The Splitview works this way that the page containing the split view will always be active (I normally call this page shell.xaml)

In here you can place your hamburger menu and add other things that should be visible all the time. Then you create a frame inside the splitview where your child pages live. handling navigation should only navigate using this frame and not the main page.

Here is a working sample that might explain this better: https://code.msdn.microsoft.com/Sample-splitview-with-edcc2ca9

Upvotes: 1

Related Questions