microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.76k stars 317 forks source link

Let UWP apps display modal windows #1228

Open JaiganeshKumaran opened 3 years ago

JaiganeshKumaran commented 3 years ago

Proposal: Let UWP apps display modal windows

Currently UWP doesn't support modal windows. While a dialog inside the window may work for most scenario, certain things may not work in a dialog and may require a separate window but the problem is it will be a full resizable windows independent of the main window which might not be a good user experience.

Summary

When you launch an app for results, the app is displayed in a modal windows. Windows should allow UWP apps to create something similar.

Modal window example

Rationale

Scope

Capability Priority
This proposal will allow developers to create a modal window (non-resizable) under UWP Must

Open Questions

The window displayed by launching result protocol is modal however it blocks input behind which has the same limitations of a dialog although can use more space since XAML content dialog has a size limit. Should there be an option to not block input but yet show a modal window that's attached to.a main window? An example would be the find and replace dialog in Excel which is attached to the main window and isn't a separate window with size limit and lets input behind.

andrewleader commented 3 years ago

Hey @Jaiganeshkumaran, have you tried using ContentDialog? You can put XAML content inside the Content property of the ContentDialog, it's a blocking modal window: https://www.c-sharpcorner.com/UploadFile/0cb003/contentdialog-in-universal-windows-program-part-1/

driver1998 commented 3 years ago

Note that account login dialog is a different app.

mqudsi commented 3 years ago

The UWP windowing model was never really changed from assuming apps would be running full screen a la the horrendous metro experience with Windows 8.

One issue I ran into before switching away from UWP was that ContentDialog and co were constrained to the boundaries of the calling CoreWindow, e.g. for a non-maximized CoreWindow that is designed to take up the amount of space it needs rather than the amount of space available on the desktop (e.g. 600x300px), a PopUp or ContentDialog could not exceed that size, either. In our case, I had to show a settings dialog that was designed to be taller than the 300px of the CoreWindow - the only way I was able to do that was to create a new window on another thread and then use many event handlers to try to intercept activation of the initial CoreWindow while the settings dialog was still active (i.e. fake modality). This necessitated adding the non-default rescap for managing (opening and closing) own-app windows, which is just a hassle to require further review for something this basic.

But as I understand it from the team, UWP is a dead-end anyway and packaged WinMain projects that have no problems creating multiple windows (on one or many threads) are the way to go, so it's a moot point.

soumyamahunt commented 3 years ago

Should there be an option to not block input but yet show a modal window that's attached to a main window? An example would be the find and replace dialog in Excel which is attached to the main window and isn't a separate window with size limit and lets input behind.

You can use InAppNotification control from community toolkit to achieve this kind of behavior. Although as far as I know it doesn't support dragging the control around like Excel's find window.

mqudsi commented 3 years ago

Hey, if it helps anyone, this is how I was creating a (effectively) modal dialog (with a new Window) on UWP before switching to WinUI:

https://gist.github.com/mqudsi/86e336004b68f8a38248122f1bec9d8b

JaiganeshKumaran commented 3 years ago

Should there be an option to not block input but yet show a modal window that's attached to a main window? An example would be the find and replace dialog in Excel which is attached to the main window and isn't a separate window with size limit and lets input behind.

You can use InAppNotification control from community toolkit to achieve this kind of behavior. Although as far as I know it doesn't support dragging the control around like Excel's find window.

That's only available for C# XAML apps and not all UWP apps.

JaiganeshKumaran commented 3 years ago

Note that account login dialog is a different app.

I know but it shouldn't need to be like that. Apps should be able to display similar windows without launching another app through protocol activation for results.

ghost commented 2 years ago

@andrewleader @btueffers this issue should be closed for the same reason (CoreWindow) #159 #173 #302 got closed.

riverar commented 2 years ago

@SeriouslyWhyIAmAGhost Can you please stop creating new accounts and stop flooding comment attempts? Every attempt you make sends a notification to every single person watching the repository. Please reach out to me (rafael@withinwindows.com) via email and we can work directly with GitHub/Microsoft to fix your account status.

Reza-Noei commented 1 year ago

Any update on this ? maybe in winui-3 at least ?

driver1998 commented 1 year ago

You don't need special support to display modal Windows with WinUI 3 (or any other desktop framework), just create a new Window (and disable the parent Window) and that's it.