简体   繁体   中英

UWP NavigationView prevent unload Pages

I'm using a NavigationView and when I navigate to a different page the previous one is unload, this is OK for some pages (and should be that way), but for other pages I wanted to maintain the Page loaded even if I navigate away from that Page.

Is this Possible?

The code for NavigationView

<NavigationView x:Name="NavigationView"
                MenuItemsSource="{x:Bind ViewModel.Items}"
                MenuItemTemplate="{StaticResource NavigationViewItem}"
                SelectedItem="{x:Bind ViewModel.SelectedItem, Mode=TwoWay}"
                SelectionChanged="OnSelectionChanged">

    <Grid>
        <Frame x:Name="frame">
            <Frame.ContentTransitions>
                <TransitionCollection>
                    <NavigationThemeTransition/>
                </TransitionCollection>
            </Frame.ContentTransitions>
        </Frame>
    </Grid>
    <NavigationView.PaneFooter>
        <NavigationViewItem ContentTemplate="{StaticResource NavigationViewItemProfile}"
                            Content="{x:Bind ViewModel.UserInfo}"/>
    </NavigationView.PaneFooter>

</NavigationView>

在其构造函数或XAML声明中,将页面的NavigationCacheMode设置为NavigationCacheMode.Required

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