We have an MvxTabbedPage
and child MvxContentPage
s in our Xamarin.Forms project.
On Android, I'm finding that the ViewAppeared
override on my first child page is not being called the first time the MvxTabbedPage
is being shown.
When switching tabs, it subsequently is being called correctly.
I'm initialising the PageModels in the ViewAppearing
for the MvxTabbedPage
's PageModel as below:
public override async void ViewAppearing()
{
await ShowInitialViewModels();
base.ViewAppearing();
}
private bool viewModelsInitialised = false;
private async Task ShowInitialViewModels()
{
if (!viewModelsInitialised)
{
await _BusyManager.SetBusy();
var tasks = new List<Task>();
tasks.Add(_MvxNavigationService.Navigate<HomePageModel>());
tasks.Add(_MvxNavigationService.Navigate<MyBenefitsPageModel>());
tasks.Add(_MvxNavigationService.Navigate<ClaimsPageModel>());
tasks.Add(_MvxNavigationService.Navigate<ContactUsPageModel>());
tasks.Add(_MvxNavigationService.Navigate<SettingsPageModel>());
await Task.WhenAll(tasks);
viewModelsInitialised = true;
await _BusyManager.SetUnBusy();
}
}
Have others seen this behaviour, and/or should I be doing something differently?
Looks like it's this Forms bug:
https://github.com/xamarin/Xamarin.Forms/issues/3855
which is referenced by this MvvmCross issue
https://github.com/MvvmCross/MvvmCross/issues/2823
(thanks to Pedro for pointing me in this direction on Slack:)