PrismLibrary / Prism.Maui

This is an experimental repo. The code here will eventually be merged into the main Prism repo as a full fledged platform at which time this repo will be archived.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Absolute navigation not updating 'Application.Current.MainPage' in Android in .Net MAUI

lakhanimilan opened this issue · comments

Description

When doing absolute navigation with '/' in .NetMaui prism, Application's current page's MainPage property is not updated to the latest page.

It is working fine with iOS.

Code
await navigationService.NavigateAsync($"/{nameof(AbsolutePage)}");

While doing this navigation following property [Application.Current.MainPage] is not updated with AbsolutePage it is showing value of old page.

Steps to Reproduce

  1. Create a maui app solution
  2. Configure with prism
  3. Do navigation with absolute navigation [await navigationService.NavigateAsync($"/{nameof(AbsolutePage)}");] from MainPage
  4. Verify Application.Current.MainPage property, it should be updated with latest page AbsolutePage.

Platform with bug

.NET MAUI

Affected platforms

Android

Did you find any workaround?

No response

Relevant log output

No response

First of all please be sure to open Prism.Maui issues in the correct repo. I have gone ahead and transferred this for you.

Second of all it is important to remember that .NET MAUI is NOT Xamarin.Forms. You should not be referencing Application.Current.MainPage. This was a concept that the team had to maintain for some slight backwards compatibility, however Prism.Maui does not make use of it at any point. As .NET Maui has a concept of 1-* application windows the appropriate thing is to iterate over the windows and get the Window.Page.