From 480c39bbdb7b82bd3fd24cc7ca749477c8dceccf Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Fri, 28 Jul 2023 17:21:32 +0330 Subject: [PATCH] Fix NavigationCache --- TvTime/Views/Pages/MainPage.xaml.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/TvTime/Views/Pages/MainPage.xaml.cs b/TvTime/Views/Pages/MainPage.xaml.cs index aaf05c1..4425c20 100644 --- a/TvTime/Views/Pages/MainPage.xaml.cs +++ b/TvTime/Views/Pages/MainPage.xaml.cs @@ -31,10 +31,29 @@ public MainPage() if (page != null && e.SourcePageType != typeof(DetailPage)) { page.NavigationCacheMode = NavigationCacheMode.Disabled; + if (MediaPage.Instance != null && CanDisableCache(e.Parameter, MediaPage.Instance.PageType.ToString())) + { + MediaPage.Instance.NavigationCacheMode = NavigationCacheMode.Disabled; + } } }; } + private bool CanDisableCache(object parameter, string pageType) + { + var parameterItem = parameter as DataItem; + + if (parameterItem != null) + { + var item = parameterItem.Parameter?.ToString(); + if (!string.IsNullOrEmpty(item) && item.Equals(pageType)) + { + return false; + } + } + return true; + } + private void MainPage_Loaded(object sender, RoutedEventArgs e) { var settings = (NavigationViewItem) NavView.SettingsItem;