I used the WinUI 3 Template in VS2022, and I created two pages according to the navigation setup, placing them in the left navigation bar for selection
For example, have Page A and Page B, the default page is Page A. Suppose I enter the number 55 in the numeric box in Page A, and when I switch to Page B When switching back to page A, 55 has already reverted to the default value
How should I modify this problem?
I hope I can keep the content of each page when I switch back and forth
You can indeed cache pages, but this is not the correct approach in your case. Caches are designed to speed up loading complex UI with many elements.
Pages are designed to be stateless and transient. You should persist all your state in dedicated classes - view models.
In other words, keep these VM objects alive, with all the values you need, like this 55. Each page should have a property of the type of its view model. When you navigate to a page, set this property to the instance of the VM. Be mindful not to create a new instance of the VM every time, but keep them alive and re-use them.