WinUI3: How to keep view alive in NavigationView, like TabView

Minh Van 171 Reputation points
2023-10-04T07:02:17.6166667+00:00

Hi,

Is there any way to keep each tab alive when navigating between tabs in NavigationView? The behavior should like TabView since the view is not refreshed if I switch back to it.

Thanks.

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
865 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jeanine Zhang-MSFT 11,341 Reputation points Microsoft External Staff
    2023-10-04T08:47:39.55+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I suggest you could try to enable a page to be cached via setting NavigationCacheMode to either Enabled or Required.

    Enabled: The page is cached, but the cached instance is discarded when the size of the cache for the frame is exceeded.

    Required: The page is cached and the cached instance is reused for every visit regardless of the cache size for the frame.

    You could set Required in the constructor for the page.

    Thank you.

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.