I have set NavigationCacheMode to Required in some pages of my WP 8.1 XAML app. How can I remove a specific page from that? This is not Navigation stack.
Asked
Active
Viewed 1,752 times
3 Answers
5
If a page has NavigationCacheMode set to Required, there is currently no way to remove it explicitly.
If you use Enabled, you can reset the cache using the cache mode:
private void ResetPageCache()
{
var cacheSize = ((Frame) Parent).CacheSize;
((Frame) Parent).CacheSize = 0;
((Frame) Parent).CacheSize = cacheSize;
}

Kai Brummund
- 3,538
- 3
- 23
- 33
1
I couldn't find a way to remove the cache however I managed to get around it by simply setting NavigationCacheMode to Disabled when I click the refresh button in my application.
So when the page reloads it is then set back to required, works a treat for me!
private void refresh_Click(object sender, RoutedEventArgs e)
{
this.NavigationCacheMode = NavigationCacheMode.Disabled;
Refresh.IsEnabled = false;
switch (flipView.SelectedIndex)
{
case 0:
ApplicationData.Current.RoamingSettings.Values["FlipView"] = 0;
break;
case 1:
ApplicationData.Current.RoamingSettings.Values["FlipView"] = 1;
break;
case 2:
ApplicationData.Current.RoamingSettings.Values["FlipView"] = 2;
break;
case 3:
ApplicationData.Current.RoamingSettings.Values["FlipView"] = 3;
break;
}
this.Frame.Navigate(typeof(MainPage));
}

alanmarklewis
- 31
- 2
0
It is too easy. Just use below code on page leave:
this.NavigationCacheMode = NavigationCacheMode.Disabled;
And use below code on page constructor:
this.NavigationCacheMode = NavigationCacheMode.Enable;

Mohammad Reza Rastegari
- 649
- 8
- 13
-
I set the cache mode to Disabled but when I navigate to that page it has the same info. Any ideas to why this is happening? – bogdanbujdea Jul 16 '16 at 13:58