PushModalAsync on Android not working in latest Visual Studio Update
See original GitHub issueDescription
Navigation.PushModalAsync appears to be broken on Android in the newest version of MAUI in Visual Studio Professional 2022 Preview 17.3.0 Preview 2
Steps to Reproduce
- Create a new .Net MAUI Project
- Create a new MAUI Content Page
- Create a modal to be opened on startup: Navigation.PushModalAsync(new ContentPage())
- Run in it in the Android Emulator
Version with bug
6.0.400 (current)
Last version that worked well
6.0.312
Affected platforms
Android
Affected platform versions
net6.0-android minimum 21.0
Did you find any workaround?
No
Relevant log output
System.InvalidOperationException: 'Current Root View cannot be null'
WORKAROUND
using Microsoft.Maui.Handlers;
namespace MauiApp32;
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new AppShell();
WindowHandler.Mapper.ModifyMapping(nameof(IWindow.Content), OnWorkaround);
}
private void OnWorkaround(IWindowHandler arg1, IWindow arg2, Action<IElementHandler, IElement> arg3)
{
WindowHandler.MapContent(arg1, arg2);
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
PushAsync is not supported globally on Android, please ...
Verify that the previous page is not using a PushModalAsync. If later you use a PushAsync, you will have the error "PushAsync is...
Read more >PushModalAsync doesn't work in Android
If I call PushModalAsync in Android I have two problems: 1) When the page calls PopModalAsync there is no handler activated in the...
Read more >Navigation.PushModalAsync() does nothing - Microsoft Q&A
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 ......
Read more >Xamarin Android application is not able to connect to MVC ...
The Issue I am facing is that the Android application is throwing an exception while connecting with MVC core web API. And here...
Read more >Xamarin Forms Navigation and physical keyboard
I was trying to solve another problem with PushModalAsync and the physical keyboard. When you are pressing the Tab key on the modal...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Wandtket @egvijayanand @dm-pr
I posted a workaround on the description that should fix your issue for now
It worked. Handler makes life easy.
Just making it simple: