0

my windows universal application is a list detail implementation. Inside the detail page i have a WebView control that is initialized with an URI. This URI is the same for each detail item because i pass to the page details data with InvokeScript function.

When i go back to detail page and i select a new item, anhoter instance of webview control is created. How can i avoid to re-download the static content of html page ? I tried to mantain a reference of Web View control up to the detail page and once a detail page is opened, push the reference inside a Grid. In this case an exception is thrown because my control is alredy child of something. What about static resource ?

Gianpolo
  • 966
  • 8
  • 19

1 Answers1

0

Have you considered this?

public sealed partial class DetailPage : Page
{
    public DetailPage()
    {
        InitializeComponent();
        NavigationCacheMode = NavigationCacheMode.Enabled;
    }
}

It allows your page to remain in cache so the next time you nav to it, you don't have to recreate everything in it. It's very handy and sounds like what you are wanting to do.

MSDN To enable a page to be cached, set NavigationCacheMode to either Enabled or Required. The difference in behavior is that Enabled might not be cached if the frame's cache size limit (CacheSize) is exceeded, whereas Required always generates an entry no matter the size limit. If you want to change the value of NavigationCacheMode programmatically to Enabled or Required, you can only set these values in the constructor for the page. If you change the value of NavigationCacheMode from Required or Enabled to Disabled, the page is flushed from the cache. The page is not simply marked as available to be flushed when the configured CacheSize is exceeded.

Best of luck

Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233