Hello,
You set Microsoft.Maui.Handlers.WindowHandler.Mapper...
, it will make all window objects to trigger the code.
For more details, please refer to .NET MAUI handlers - .NET MAUI | Microsoft Learn
You could try to find the WindowHandler
of the first window, then call the platform-specific code. It won't affect the second window.
For example:
If you set the first window like this: Window firstWindow = new Window(new MyPage());
You could find the window in the Loaded
method of MyPage
(The root page of the first window might be AppShell, you could find the window in the Loaded
method of AppShell
)
public partial class MyPage : ContentPage
{
public MyPage()
{
InitializeComponent();
this.Loaded += MyPage_Loaded;
}
private void MyPage_Loaded(object sender, EventArgs e)
{
var handler = this.Window.Handler as Microsoft.Maui.Handlers.WindowHandler;// find the handler and platform view
var mauiWindow = handler.VirtualView;
var nativeWindow = handler.PlatformView;
//... call the hide title bar method
}
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.