Beispiel #1
0
        public static async Task <bool> OpenNewWindowAsync(Type page)
        {
            var    currentAV = ApplicationView.GetForCurrentView();
            Window newWindow = null;
            var    newAV     = CoreApplication.CreateNewView();
            bool   result    = false;
            await newAV.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                async() => {
                newWindow      = Window.Current;
                var newAppView = ApplicationView.GetForCurrentView();

                newAV.CoreWindow.Closed += (a, b) => CoreApplication.DecrementApplicationUseCount();
                CoreApplication.IncrementApplicationUseCount();
                newAppView.SetPreferredMinSize(new Size(360, 500));

                newWindow.Activate();
                await Task.Yield();
                var frame = new Frame();
                frame.Navigate(page);
                newWindow.Content = frame;

                result = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newAppView.Id, ViewSizePreference.Custom, currentAV.Id, ViewSizePreference.Custom);
            });

            return(result);
        }