1
votes

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:

  • Removing the parameters from the call.
  • Changing “ItemDetailsPage” to “/ItemDetailsPage” or “NavigationPage/ItemDetailsPage”.
  • Adding useModalNavigation: true to the call.
  • Navigating to another of the previous pages with NavigateAsync.

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.

1
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 or something like that, wich 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 error problems, (incorrect bindings, null bindings, incorrect syntax, whatever)Ricardo Dias Morais
This problem did manifest itself on this very page before, because, I think, I had too many bindings. I'll revert my code and investigate this route furtherBlanthor
@RicardoDiasMorais you were right. I was binding an Entry to a double property. When I changed this to a string property, I was able to navigate to the page. Change your comment to an answer, and I will give you credit.Blanthor
did it, and thank you :) i'm glad i could helpRicardo Dias Morais

1 Answers

1
votes

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).