A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hi @Eduardo Gomez ,
Thanks for reaching out.
For more details, you can refer to this article: UITitlebar
While this is a non-Microsoft link, it’s official Apple Developer documentation and is safe to visit.
From the code and the picture you show, you want to make possible on mac like this: hide title bar, lock size and start fullscreen. While the window code you shared already solves it on Windows, for macos you need to separate platform-specific implementation.
You may refer to the code below:
Note: run this after the MAUI window is created (for ex: in Window.Created or by overriding CreateWindow).
MacWindowHelper.cs
#if MACCATALYST
using System;
using System.Linq;
using Foundation;
using UIKit;
public static class MacWindowHelper
{
public static void ConfigureMainWindow()
{
var scene = UIApplication.SharedApplication
.ConnectedScenes
.OfType<UIWindowScene>()
.FirstOrDefault();
if (scene is null)
return;
var window = scene.Windows.FirstOrDefault();
if (window is null)
return;
if (scene.Titlebar is not null)
scene.Titlebar.TitleVisibility = UITitlebarTitleVisibility.Hidden;
scene.RequestGeometryUpdate(
new UIWindowSceneGeometryPreferencesMac(UIMacOSWindowSize.FullScreen),
error => { });
NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds(400), _ =>
{
var size = window.Bounds.Size;
scene.SizeRestrictions.MinimumSize = size;
scene.SizeRestrictions.MaximumSize = size;
});
}
}
#endif
App.xaml.cs
using Microsoft.Maui.Controls;
public partial class App : Application
{
public App()
{
InitializeComponent();
}
protected override Window CreateWindow(IActivationState? activationState)
{
var window = base.CreateWindow(activationState);
#if MACCATALYST
window.Created += (_, __) => MacWindowHelper.ConfigureMainWindow();
#endif
return window;
}
}
Note: if you just care about the hidden title bar, just care this:
if (scene.Titlebar is not null)
scene.Titlebar.TitleVisibility = UITitlebarTitleVisibility.Hidden;
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.