OpenWindow displays a supplied Window instance, allowing a .NET MAUI application to show a ContentPage in a separate window. Desktop applications commonly use this pattern for secondary pages such as About screens. section 10.3.3
To open a page in a new window:
- Create a Window and pass an AboutPage to its constructor. section 10.3.3
- Set useful window properties such as Title, Width, and Height. section 10.3.3
- Call Application.Current.OpenWindow with the configured instance. section 10.3.3
- Connect the operation to a command, such as a Help > About menu item. section 10.3.3
Opening an About window
A ReportViewModel can create a 300-by-300 Window titled “About,” place an AboutPage inside it, and pass it to Application.Current.OpenWindow. A ShowAboutPageCommand can invoke this method from the ReportPage menu. section 10.3.3
Listing 10.21 The ShowAboutPage method in ReportViewModel
public void ShowAboutPage()
{
var newWindow = new Window(new AboutPage())
{
Title = "About",
Width = 300,
Height = 300
};
Application.Current.OpenWindow(newWindow);
}
Inspect the complete ShowAboutPage implementation, including Window construction, property assignment, and the OpenWindow call. section 10.3.3
Windows work on Windows and Android in this scenario. Enabling multiwindowing on macOS and iOS additionally requires a SceneDelegate and UIApplicationSceneManifest settings in info.plist. section 10.3.3
