简体   繁体   中英

How to set up XAML View Content in Different XAML

I just programm a Windows Universal App and I want to set up an empty MainView.xaml witch provides the content from different User Control xamls just like in javafx and switch then on the fly in the MainViewxaml.cs like:

Pseudo Code:

this.Content = Login.xaml

Main.xaml Pseudo Code:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <UserControl x:Name="UserControl"/>
</Grid>

My Question is:

How can I do this in a Windows Universal app ?

Use a frame and pages. Or if you don't want to do that, use a ContentControl.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <ContentControl x:Name="ContentControl">
        <UserControl x:Name="UserControl"/>
    </ContentControl>
</Grid>

And than you can say ContentControl.Content = new YourUserControl();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM