Search code examples
c#xamlwinui-3.net-7.0windows-app-sdk

WinUI3 WindowsApp State Management


I'm looking to create state management for a Windows App desktop. It seems when going to back and forth from pages, the controls don't maintain their values. Do I have to cache the controls?


Solution

  • You need to set NavigationCacheMode to Required in pages that you want them to be cached while navigation.

    <Page
      ...
      NavigationCacheMode="Required"
      ...
    />