Why the Change?
In .NET 9, you use CreateWindow
to set up the main window. This helps manage the app lifecycle better and supports multiple windows.
Is It Necessary?
Yes, it’s required in .NET 9. The old MainPage
property is deprecated.
Relevance for Mac and Windows
This change applies to both macOS and Windows.
Here’s the code:
protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new AppShell());
}