如何在 UWP 中制作模态 Window 并在关闭时制作 return 值

How to make modal Window in UWP and return value when it is closed

我需要在 UWP.

中立即 Window 实现一些功能

所以我想做以下事情

  1. Start new Window in a Modal state so parent Window cannot be acceced.
  2. On closed event return value to the parent Window.

我使用下面的代码创建一个新的Window请帮我存档这些点

private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var switchToView = true;

            var newView = CoreApplication.CreateNewView();
            int newViewId = 0;
            await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame = new Frame();
                frame.Navigate(typeof(MyCam), null);
                Window.Current.Content = frame;

                newViewId = ApplicationView.GetForCurrentView().Id;
            });
            var viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
            if (switchToView && viewShown)
            {
                // Switch to new view
                await ApplicationViewSwitcher.SwitchAsync(newViewId);
            }            
        }

我在这里找到了很好的解决方案 https://github.com/bkaankose/UWPModalDialogHelper

即将使用 Prism.Core Nuget 包来模拟带有自定义 UserControl 的全屏弹出窗口。