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.72k stars 308 forks source link

Modal dialog please Help #2604

Open jcarnalich opened 2 years ago

jcarnalich commented 2 years ago

Discussed in https://github.com/microsoft/WindowsAppSDK/discussions/2603

Originally posted by **jcarnalich** June 9, 2022 Hello, we are a company from software development. We have programs made in **MFC/C++** with thousands of customers. We want to migrate our products from **MFC/C++** to **WinUI 3**. > The main problem is that we use many modal dialogs. Many times from a modal dialog opens another modal dialog, and another... (see screenshot): ![example_mfc](https://user-images.githubusercontent.com/19662787/172792732-68bfc810-eef7-403a-b64d-f3ffdffd9105.png) I have two questions: > **1° plans Windows to do this type of modal dialogs in the future? 2° Is it possible to make modal dialogs from other modal dialogs with the current version of winui ?** > we have tried to do the following without success: > a) **Contentdialog/Flyout**. It's ok but you can't open another Contentdialog/Flyout from a Contentdialog/Flyout. b) Do it manually with **UIElement.GotFocus** Event. c) **Windowing**. AppWindowPresenterKind.CompactOverlay. It's ok but you can't open another Window (modal with CompactOverlay) from a Window. d) WinUI Extensions : **WinUIEx**. (It's based also in Windowing) It's ok but you can't open another WinUIEx from one WinUIEx. e) Do it manually with **Canvas**, ManipulationMode="TranslateX, TranslateY, TranslateInertia", Visibility.Collapsed/Visible, IsHitTestVisible? > Could you please help us? Thanks in advance! Best regards
codendone commented 1 year ago
  1. Yes, modal dialogs will be supported in a future release.
  2. Yes, it is possible to make a modal-like experience today, by just showing new Windows which are parented to existing Windows and disabling/enabling the parent window when showing/closing the dialog. The main catch is that nested message pumps are not supported, so code needs to be written to show the dialog and unwind to the main message pump, and any handling on close of the dialog needs to be done in appropriate event handlers (for window close, or on the OK button of the dialog, or wherever).