uwp How To Show a LoginWindow and lock the MainWindow

时间:2017-05-16 09:23:28

标签: c# uwp

Hello. How do I display a LoginForm in UWP and lock MainWindow when displayed?. Just like showdialog () in WPF. The following code shows a new form coming out

I Need a modal window

     static bool viewShown = false;`enter code here`
                static bool viewClosed = false;
                static int newViewId;
                static int currentViewId;
                static Frame frame;

            private async void btnUserLogin_Click(object sender, RoutedEventArgs e)
            {
                CoreApplicationView newView = CoreApplication.CreateNewView();
                if (viewShown)
                {
                    if (viewClosed)
                    {
                        await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
                        viewClosed = false;
                    }
                    else
                    {
                        await ApplicationViewSwitcher.SwitchAsync(newViewId);
                    }
                }
                else
                {
                    await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        var newWindow = Window.Current;
                        var newAppView = ApplicationView.GetForCurrentView();
                        newAppView.Consolidated += NewAppView_Consolidated;
                        newAppView.Title = "登录";
                        ApplicationViewTitleBar titleBar = newAppView.TitleBar;

                        // Title bar setting                    
                        //......

                        frame = new Frame();
                        frame.Navigate(typeof(LoginPage));
                        newWindow.Content = frame;
                        newWindow.Activate();

                        newViewId = newAppView.Id;
                    });
                    viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
                }

            }

But this did not lock the main interface

0 个答案:

没有答案