Hello,
I am quite new in Xamarin dev.
We have built a simple application based on MasterDetailPage navigation pattern.
In each detail page we have a webview with each a different URL loaded.
Any time we display a detail page, the webview is reloaded.
Do you know how it is possible to prevent this reload if the webview have been reloaded once before ?
We would like the webviews to be loaded only once as it is working on NavigationPage pattern. (when we popAsync a page, the previous page is displayed without reloading the webview)
Thank you for your help.
If you want to keep the previous state we need to use the existed instance instead of instantiating a new one when changing the detail page.
For example, let's take a look at the official Master-Detail Page template. Here is the navigating method:
public async Task NavigateFromMenu(int id) { if (!MenuPages.ContainsKey(id)) { switch (id) { case (int)MenuItemType.Browse: MenuPages.Add(id, new NavigationPage(new ItemsPage())); break; case (int)MenuItemType.About: MenuPages.Add(id, new NavigationPage(new AboutPage())); break; } } var newPage = MenuPages[id]; if (newPage != null && Detail != newPage) { Detail = newPage; if (Device.RuntimePlatform == Device.Android) await Task.Delay(100); IsPresented = false; } }
It will retrieve the existed detail page which is stored in MenuPages
. Instantiate a new one if it hasn't been created before. But if we can find it in that dictionary we could use it directly.
Here is the effect:
The detail information page is persisted there.
Answers
If you want to keep the previous state we need to use the existed instance instead of instantiating a new one when changing the detail page.
For example, let's take a look at the official Master-Detail Page template. Here is the navigating method:
It will retrieve the existed detail page which is stored in

MenuPages
. Instantiate a new one if it hasn't been created before. But if we can find it in that dictionary we could use it directly.Here is the effect:
The detail information page is persisted there.
Thank you so much for your reply.
We have tried the same approach but doesn't work.
Do you mind sending us the whole source project?
Thank you for your help.
I used the default template for Master-Detail page and embed a simple webview on one of the detail pages. Try to share your samples here to help us reproduce your issues.
Hello,
Thank you for your answer.... It works!
Just a last question... Do you know if it is possible to keep the scroll position ?