Reputation: 2680
With Xamarin.Forms 4.0 and Prism 7.1.04 with AutoFac, I cannot navigate to the last page in my stack. I have registered all of my pages in App.xaml.cs. Navigation up to the last page works successfully. When NavigationAsync is called for this last page, the constructors for both the Page and the ViewModel are entered, but the page doesn't render.
Things I have tried that don’t work:
useModalNavigation: true
to the call. I can use the NavigationService to navigate back with GoBackAsync.
In App.xaml.cs, I have registered the following types:
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// Register Pages for Navigation
containerRegistry.RegisterForNavigation<NavigationPage>();
containerRegistry.RegisterForNavigation<LoginPage, LoginViewModel>();
containerRegistry.RegisterForNavigation<CustomerSearchPage, CustomerSearchViewModel>();
containerRegistry.RegisterForNavigation<ConsentPage, ConsentViewModel>();
containerRegistry.RegisterForNavigation<RequestPage, RequestViewModel>();
containerRegistry.RegisterForNavigation<BankContextPage, BankContextViewModel>();
containerRegistry.RegisterForNavigation<CollectionEventsPage, CollectionEventsViewModel>();
containerRegistry.RegisterForNavigation<CollectionDetailsPage, CollectionDetailsViewModel>();
containerRegistry.RegisterForNavigation<CollectionItemsListPage, CollectionItemsListViewModel>();
containerRegistry.RegisterForNavigation<ItemDetailsPage, ItemDetailsViewModel>();
// ...
}
The work flow begins at the LoginPage and proceeds from one page to another in a linear fashion, until it reaches the eighth page. I cannot navigate to the ninth page for some reason.
App.xaml.cs: await NavigationService.NavigateAsync("NavigationPage/LoginPage");
LoginPage.xaml.cs: await NavigationService.NavigateAsync("CustomerSearchPage");
CustomerSearchViewModel.cs: await NavigationService.NavigateAsync("ConsentPage");
ConsentViewModel.cs:
var parameters = new NavigationParameters();
parameters.Add("consent", consent);
await NavigationService.NavigateAsync("RequestPage", parameters);
RequestViewModel.cs: await NavigationService.NavigateAsync("BankContextPage");
BankContextPageViewModel.cs: await NavigationService.NavigateAsync("CollectionEventsPage", parameters);
CollectionEventsViewModel.cs: var ret = await NavigationService.NavigateAsync("CollectionItemsListPage");
CollectionItemsListViewModel.cs: status = await NavigationService.NavigateAsync("ItemDetailsPage”, parameters); //This fails
Does this mean that I have run out of memory?
When debugging, the behavior in the debugger is as if I have left the CollectionEventsViewModel. There is no longer any debug information in that view model. There is no return value to the call to
status = await NavigationService.NavigateAsync("ItemDetailsPage”);
No exception is caught either. I am developing this app on a Mac for iOS and Android. Stepping through the code doesn't seem to tell me everything. I'm not sure what diagnostic tools might tell me more.
Upvotes: 1
Views: 1052
Reputation: 2087
Probably in the last page you have some error in the xaml or something like that, i had this problem once and it was because i had a custom render for a label and in the iOS render i didn't check for a null, that caused the page not to render, and i though for hours that it was a Navigation problem, when it wasn't, so make sure that you don't have any UI errors, (incorrect bindings, null bindings, incorrect syntax, whatever).
Upvotes: 2