Upgrading to XF 5.0.0.2012 fixes the problem as I reported in the bug tracker (https://github.com/xamarin/Xamarin.Forms/issues/13741#issuecomment-778748400). So the problem was indeed a bug in XF and not in my own code but unfortunately I couldn't find the fixing commit in the history between XF 5.0.0.1931 and XF 5.0.0.2012.
Navigation.PushModalAsync() does nothing

Hello,
I've a Shell-based XF app and upgraded recently from 4.6.0.847 to (currently) 5.0.0.1931.
On some page, I handle a tap event like that:
void OnEditClicked(System.Object sender, System.EventArgs e)
{
// Additional security check
if (!(viewModel.Person.CanEdit ?? false))
return;
var editProfilePage = new EditProfilePage
{
BindingContext = new PersonEditProfileViewModel(App.PhoneFeatureService, App.Service, viewModel.Person)
};
// Trick to get a modal yet with toolbar and title:
Navigation.PushModalAsync(new NavigationPage(editProfilePage));
}
The code is properly executed but Navigation.PushModalAsync does... nothing! I tried to remove my trick with the NavigationPage but it does not help either.
Tried to replace with Application.Current.MainPage.Navigation.PushModalAsync but does not help either.
If I replace with a standard Navigation.PushAsync(), thus no modal, then the page shows up, but naturally I need the modal behaviour.
Any idea?
Developer technologies | .NET | Xamarin
2 additional answers
Sort by: Most helpful
-
Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
2021-02-12T04:46:54.583+00:00 Hello,
Welcome to Microsoft Q&A!
Try to replace
Navigation.PushModalAsync(new NavigationPage(editProfilePage));
With
Shell.Current.Navigation.PushModalAsync(new NavigationPage(new editProfilePage()));
It works fine on my side .
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
Stesvis 1,041 Reputation points
2021-02-13T00:03:48.373+00:00 When this happens to me it's 99% of the time a XAML error in the next page that you are trying to load.
Most of the times for me it's because I use a {StaticResource} that doesn't exist or is mispelled...I use Prism and this code helps print out what's wrong:
var result = await NavigationService.NavigateAsync(path); if (!result.Success) { System.Diagnostics.Debug.WriteLine(result.Exception.ToString()); }