I'm having trouble figuring out how to cache pages already visited in my silverlight application. I have an array of URIs declared like so:
let pages : UriUserControl array = [|
new Module1.MyIdeas() :> UriUserControl ;
new Module1.Page2() :> UriUserControl ;
new Module1.Page3() :> UriUserControl ;
new Module1.Page4() :> UriUserControl ;
new Module1.Page5() :> UriUserControl ; |]
I have a navigation frame on the page and I handle the navigation like so (nav is the Frame object on the template page):
member this.navigate (ea: SelectedMenuItemArgs) =
let i = ea.Index
if i <= pages.Length then
let page = (pages.[i-1] :> INamedUriProvider)
nav.Navigate(page.Uri) |> ignore
pageTitle.Text <- page.ProviderName
I'm looking for a way to avoid re-creating the page on subsequent navigations to the URI. I thought of keeping a map of URI -> nav.Content but nav.Content and setting the navs content based on this cache. Any ideas?