maui
maui copied to clipboard
Multi-Window in Windows with all options
Description
Hi.
Are there plans for the multi-windows feature to have all the options found in WPF windows?
Ex: hide title bar, open new window in modal mode, disable/hide minimize/maximize/close buttons, set new window position, open new window in full screen, resizable or fixed border, show/hide the icon in the taskbar, etc.
I have a WPF program that I am studying its future migration to MAUI. Unfortunately UWP is very limited in multi-windows. My program detects how many monitors are installed and opens a second window on the secondary monitor, full screen, no title bar, no minimize, maximize and close buttons.
Is the MAUI project on Windows heading in that direction: empowering the programmer? Or is Application.Current.OpenWindow() the most we can hope for a long time?
Grateful for the time and effort. Hugs from Brazil.
Public API Changes
Window window = new Window
{
Title = "My Modal Window",
CanMinimize = false,
CanMaximize = false,
StartPosition = Positions.CenterScreen,
BorderStyle = BorderStyles.Fixed,
ShowIconTaskBar = false,
Modal = true,
Page = new MyPage()
};
Application.Current.OpenWindow(window);
Intended Use-Case
Make the OpenWindow() feature useful.
THIS IS MY OPINION
MAUI is the base level of what platforms it offers, right? The kind of API your thinking about would only really make sense for Desktop only, and most of its features really only for Windows.
You can always get the root platform window from MAUI into a WinUI window (By calling on the Window Platform view) and do many things you want right now. You don't need an explicit API for that in the MAUI platform, nor, IMO, does it make sense for them to maintain.
It makes more sense for your idea, IMO, to be an extension off of IWindow
to make a new Platform Window that could go into the Community Toolkit than something built into MAUI itself.
MAUI will be executed in Windows, MacOS, Linux... All desktop platforms, all with windows.
IWindow will just ignore "PropertyToDesktop" in "new Window { PropertyToDesktop = value }" if running in Android, iOS, Tizen...
if(Application.Platform.ThisPlatformCanMinimizeWindow) { ... } else { // do nothing}
Just a note on some progress, we have added the sizing options. Not quite the StartPosition = Positions.CenterScreen
, but we do have a set of properties (X
, Y
, Width
, Height
).
This can be used in conjunction with DeviceDisplay.Current.MainWindowInfo
to determine the desired, centered rectangle.
We also have the Title
property.
Fow the other features (if they are available in WinUI) can be accessed via:
(myWindow.Handler.PlatformView as Microsoft.UI.Xaml.Window).xxxx
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Any updates?
No
Providing the ability to create multi-window desktop applications with a range of customizable options, such as hiding the title bar, opening new windows in modal mode, disabling or hiding minimize/maximize/close buttons, setting the new window position, opening new windows in full screen, and showing or hiding the icon in the taskbar, can be a powerful and flexible feature for desktop apps.
This feature can allow users to work with multiple windows or views simultaneously, and customize the interface to their specific needs and preferences. For example, users may prefer to work with multiple windows side-by-side, or to have a single large window that fills the entire screen.
By providing a range of options for customizing the appearance and behavior of windows, the application can adapt to different usage scenarios and workflows, and provide a more efficient and effective user experience.
Related to this I opened this feature request, to choose which screen a window will open. Very useful for scenarios with multiple monitors. Today when I open a new window, it opens on the main monitor. This can harm the experience because I have the application on monitor X and when I have an action to open a new window, many times a window that refers to the content that I am showing this new window opens on monitor Y.
[Window] Choose the screen that the window will open https://github.com/dotnet/maui/issues/13777
Here's an example in WPF to define which monitor a new window will open in scenarios where you have multiple screens:
// Get a list of all the available screens
var screens = System.Windows.Forms.Screen.AllScreens;
// Find the secondary screen
var secondaryScreen = screens.FirstOrDefault(s => !s.Primary);
// Create a new window
var newWindow = new Window();
newWindow.Title = "New Window";
// Set the window's position and size to the bounds of the secondary screen
if (secondaryScreen != null)
{
newWindow.Left = secondaryScreen.WorkingArea.Left;
newWindow.Top = secondaryScreen.WorkingArea.Top;
newWindow.Width = secondaryScreen.WorkingArea.Width;
newWindow.Height = secondaryScreen.WorkingArea.Height;
}
// Show the new window
newWindow.Show();
The saddest part is electron has this feature long time ago...
To make this work, you can create a derived window class or use attached properties. To make things work, it is easy to add a new mapper for your properties and do whatever is needed.