CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier

Home Page:https://learn.microsoft.com/dotnet/communitytoolkit/maui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[♻️ Housekepping] Until .NET 9 we should avoid Application.MainPage

pictos opened this issue · comments

The .NET MAUI team is deprecating the usage of Application.MainPage because it, normally, isn't what devs/we expect to be. In a MultiWindow scenario it can return the wrong Page.

One way to workaround this is to change Application.Current.MainPage to Application.Current.Windows[0].Page.

At least for me, isn't 100% clear what Windows[0] means:

  • it's the first window at collection
  • it's the topmost window
  • it's the focused window

For join the discussion at .NET MAUI repo, please go here.

Maybe, today we already have a bug for multi-window apps, but since no user has reported any issue we don't need to rush on this.