View Model loads Every time in Bottom Navigation Bar

Ravi_98Ravi_98 Member ✭✭

I'm using MVVM cross for my xamarin cross platform app. Using Bottom navigation in my home page, the one issue which I'm facing is whenever I navigate between the tabs, the view model loads every time which makes the app to load each and every time I navigate between tabs. How to avoid the view models reloading each time. For navigation I am using the below code

await NavigationService.Navigate<MyViewModel>().ConfigureAwait(false);

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited June 2019

    Trying to keep the page in memory is a huge pain and has many unexpected side effects, so it's best to recreate the page. Just like below:

    await Navigation.PushAsync(new Page());
    

    To avoid the problem, you can use code-behind to manually control this issue or register your pages with the container as a singleton.
    Refer to: https://github.com/PrismLibrary/Prism/issues/968

Sign In or Register to comment.