iNKORE-NET / UI.WPF.Modern

Modern (Fluent 2) styles and controls for your WPF applications
https://docs.inkore.net/ui-wpf-modern
GNU Lesser General Public License v2.1
326 stars 29 forks source link

Is it possible to implement NavigationCacheMode? #35

Closed kevwkev closed 5 months ago

kevwkev commented 5 months ago

Can NavigationCacheMode be implemented to ensure that page changes are preserved when switching between pages in a NavigationView?

NotYoojun commented 5 months ago

I can't understand your idea now. Could you be more specific? NavigationView gives you a bunch of items for you to choose from for navigating. What really controls the page is the ui:Frame. If you need you have a better control of the pages, I strongly recommend you use this method:

public bool Navigate(object content, NavigationTransitionInfo infoOverride)

instead of:

public bool Navigate(Type sourcePageType, object parameter, NavigationTransitionInfo infoOverride)

I hope my idea above can work this issue out!

kevwkev commented 5 months ago

Setting up a NavigationView and navigating between pages poses no challenges. The inquiry I had pertained to the page content. Consider two pages, Page 1 and Page 2. Page 1 includes a textbox where we input text. Upon switching to Page 2 and then back to Page 1, the previously entered text in the TextBox is lost. This issue can be resolved by enabling NavigationCacheMode in WinUI3.

NotYoojun commented 5 months ago

Oh but you need to use ui:Frame to navigate between pages. Later i may write you an example.

kevwkev commented 5 months ago

Yes, I understand. I am utilizing UI:Frame. As stated earlier, there are no problems with page navigation. This is merely a plea to incorporate the NavigationCacheMode feature. https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.page.navigationcachemode?view=winrt-22621

NotYoojun commented 5 months ago

For the ui:Frame

Don't use this:

public bool Navigate(Type sourcePageType, object parameter, NavigationTransitionInfo infoOverride)

Instead, USE THIS:

public bool Navigate(object content, NavigationTransitionInfo infoOverride)