Exploring multi-window support for Linux, macOS, and Windows

Dual screen, Split-screen, or Fullscreen, whichever describes your workspace, we live in a time of heightened productivity and seamless multitasking. So, shouldn’t your app’s UI extend beyond a single window and let users interact with multiple components simultaneously without the need to toggle back and forth?

The short answer is yes, though the use case is much more evident for desktop users than mobile ones. Thankfully, if you’re an Uno Platform developer, the latest release introduces multi-window support for Windows, macOS, and Linux, so you can create richer, more engaging applications that can effectively multitask and handle complex workflows.

In this blog, we’ll explore the new multi-windowing feature, walk through its implementation, and share practical examples to help you integrate it into your Uno Platform projects.

Multi-Window Support Overview

What is Multi-Window Support?

Multi-window support allows applications to operate in more than one window at the same time. This feature is vital for desktop environments where users benefit from interacting with multiple datasets or interfaces concurrently.

Implementation

Multi-window capabilities are built into the Uno Platform by leveraging native operating system APIs, ensuring that additional windows perform as native ones on each platform. It allows for multiple windows to run simultaneously on the same UI thread, which simplifies communication between windows without the need for synchronization or dispatchers.

This means that each window can have its own set of resources and be independently managed. The entire system is rendered using Skia, ensuring a native appearance and consistent text presentation across all application content, complete with expected features.

This approach allows for a more scalable application design and can be crucial for applications that need to display a significant amount of independent data or interfaces simultaneously.

Key Features
  • Native Performance: Leveraging native APIs allows for smooth and responsive multi-window operations.
  • Independent Resource Management: Each window can manage its resources, making the application scalable and robust.
  • Consistent UI Rendering: The use of Skia ensures that the text and visuals remain consistent across all windows.
Uno Platform Windowing Sample
Sample code available on the Uno Platform repo.

Practical Applications and Benefits

Enhanced Productivity

Multi-window support allows users to handle multiple documents or views simultaneously, significantly reducing the need for switching contexts.

Improved User Engagement

By providing tailored window behaviors, applications can offer more dynamic and immersive user experiences.

Greater Flexibility

The ability to customize window configurations enables applications to adapt seamlessly to various user scenarios, from professional environments to more casual settings.

It also might prevent your users from feeling like this:

Window Management

Standard Window Creation

Developers can quickly spawn new windows using the Microsoft.UI.Xaml.Window class, which behaves similarly across platforms thanks to Uno’s consistent API surface. This allows for the straightforward instantiation of new windows with minimal overhead.

Custom Window Types

For applications requiring specialized window behaviors and unique layouts or those who prefer working directly with XAML, Uno Platform accommodates this by creating custom window types. By inheriting from the Window class, developers can define their own window logic and UI in XAML with supporting code-behind, harnessing the full power of XAML styling and templating.

Each custom window utilizes a `.xaml` file along with a corresponding `.xaml.cs` code-behind file, containing both the UI elements and the logic required for operations such as incrementing window counters and generating dynamic background colors. This approach enables developers to easily craft and showcase customized UIs within their windows.

Advanced Customization with AppWindow

The AppWindow property offers advanced customization options, including window presentation – where developers can easily minimize or maximize the window, keep it on top of other windows, or switch it to full-screen mode.

Implementation Example

How to Create a Window

To create a multi-window setup, start by creating a new window instance, configuring its UI, and setting the UI to the window’s content property. The window is then made visible through an activation method.

Basic Multi-Window Setup

Here’s a straightforward example of how easily multi-window can be implemented with Uno.

				
					var newWindow = new Window();
newWindow.Content = new MainPage();
newWindow.Activate();


				
			

TODO Minimize and Maximize via OverlappedPresenter 

				
					e.g. ((OverlappedPresenter)AppWindow.Presenter).Maximize())
				
			

Fullscreen

Here is an example that toggles the application’s main window into fullscreen mode. 

				
					var app = Application.Current as App;
App.MainWindow.AppWindow.SetPresenter(Microsoft.UI.Windowing.AppWindowPresenterKind.Overlapped);

				
			

Window Title Feature

The window title feature exemplifies simple property settings, such as setting `window.title` to a text string, which can also be data-bound to other UI elements like a text box. This enables two-way data binding, allowing changes in the text box to be reflected in the window’s title bar.

Watch our Windowing demo from the Uno Platform 5.2 Webinar

Additional Resources
For detailed guidance on integrating multi-window support, visit our documentation.

Next Steps

If you haven’t already, install the Uno Platform extensions, then start by exploring our samples and tutorials to get hands-on experience.

And don’t forget to join the Uno Platform community

Tags:

Related Posts

Uno Platform 5.2 LIVE Webinar – Today at 3 PM EST – Watch