adminSoftDK
adminSoftDK

Reputation: 2092

Universal app difference between page and usercontrol, and how to create static regions

I started to play with universal apps yesterday, and there is few things which confuse me. In WPF we have window or usercontrol, and these are clear to me, however in universal app there is a page and usercontrol as well, and I'm confused when to actually use page over usercontrol (because some stuff like nivigation in prism looks for pages not for usercontrols). I also cannot find how to switch usercontrols/pages, without the need to navigate the entire thing. So let’s say I have a header and a footer section, I want them to be consistant as the dont change. In WPF I use prism, to create regions, and I only navigate inside the regions, it does not look like there is a way to do it in Universal app, or is there? I don't want to repeat the same stuff on all pages/usercontrols etc. Any advices please, I tried to look online but not much information about achieving this stuff.

Upvotes: 0

Views: 2353

Answers (1)

Jeffrey Chen
Jeffrey Chen

Reputation: 4680

In WPF we have window or usercontrol, and these are clear to me, however in universal app there is a page and usercontrol as well

The WPF XAML Framework and UWP XAML Framework have some different design.

WPF:

public class Window : ContentControl, IWindowService

UWP:

public class Frame : ContentControl, IFrame, INavigate, IFrame2, IFrame3
public class Page : UserControl, IPage, IPageOverrides

Frame vs. Window

WPF is a Windows desktop application, so it uses the Window as the root element. UWP introduced a build-in navigation model, the page is in a frame and the frame has the ability to navigate between pages.

So let’s say I have a header and a footer section, I want them to be consistant as the dont change.

You can put the navigable content in a sub-frame.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <StackPanel>
        <TextBlock>Header</TextBlock>
        <Frame x:Name="pages">
            <TextBlock>Content</TextBlock>
        </Frame>
        <TextBlock>Footer</TextBlock>
    </StackPanel>
</Grid>

enter image description here

Upvotes: 3

Related Questions