0

I have application UWP

image

Left screen is SplitView.Pane with list content.

Right screen is SplitView.Content, contain detail of content.

<SplitView.Content>
    <Frame x:Name="frMainFrame">
        <Frame.ContentTransitions>
            <TransitionCollection>
                <NavigationThemeTransition />
            </TransitionCollection>
        </Frame.ContentTransitions>
     </Frame>
</SplitView.Content>

When im clicked into title on the SplitView.pane, frMainFrame will navigate into ListThread page with parameter is "id"

frMainFrame.Navigate(typeof(ListThread), id);

Method handled Back button

private void OnBackRequested(object sender, BackRequestedEventArgs e)
{           
    if (frMainFrame.CanGoBack)
    {
        e.Handled = true;
        frMainFrame.GoBack(new SuppressNavigationTransitionInfo());
    }
    else
    {
        DialogResult.AskToExitApp();
    }
}

On ListThread page,

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    if (e.NavigationMode != NavigationMode.Back)
    {
        idBox = (int)e.Parameter;
        Idpage = 1;
        AnalyzeUrlBox();
        AnalyzeHtml();
    }
}

and set NavigatitonCacheMode is Required on Constructor method:

this.NavigationCacheMode = NavigationCacheMode.Required;

Now,

  1. I'm click on Modding and wait for content load complete.(frMainFrame will navigate in to ListThread with Parameter Id = 2)
  2. I'm click on AMD and wait for content load complete.(frMainFrame will navigate in to ListThread with Parameter Id = 3)
  3. I'm click on Back button on the top corner left.

    • Require: frMainFrame navigate display ListThread with Parameter Id = 2, restore all state before navigate

    • Actual: frMainFrame stuck on ListThread with Parameter Id = 3

I think, the problem lies in NavigationCacheMode. How to what to execute same as Require?

Thanks!

FredM
  • 454
  • 9
  • 20
  • Did you tried to set `this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;` ? – MKH Nov 27 '18 at 07:53
  • I have try and seems as problem was not resolve. I think that the problem at each page only only 1 instance cache. If me navigation from ListThread to page Thread.Xaml, click backbutton, the ListThread is Restore the complete. – nvcuong1312 Nov 27 '18 at 08:02
  • `Frame.GoBack()` Navigates to the most recent item in back navigation history such as ([Pages](https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.page)) , So I think you should try to create `new` Instances for each item (AMD,Modding , ...) and navigate to it to preserve history and keep loaded data. – MKH Nov 27 '18 at 08:21
  • 1
    I tried with search with your help and succeeded. https://stackoverflow.com/questions/11539755/winrt-uwp-frame-and-page-caching-how-to-create-new-page-instance-on-navigate Thanks! – nvcuong1312 Nov 27 '18 at 10:18

0 Answers0