|
34 | 34 | using Windows.UI; |
35 | 35 | using Windows.UI.Core; |
36 | 36 | using Windows.UI.Popups; |
37 | | -using Windows.UI.WindowManagement; |
38 | | -using Windows.UI.WindowManagement.Preview; |
| 37 | +using Windows.UI.ViewManagement; |
39 | 38 | using Windows.UI.Xaml; |
40 | 39 | using Windows.UI.Xaml.Controls; |
41 | 40 | using Windows.UI.Xaml.Hosting; |
@@ -527,9 +526,6 @@ public void ShareItem_Click(object sender, RoutedEventArgs e) |
527 | 526 | DataTransferManager.ShowShareUI(); |
528 | 527 | } |
529 | 528 |
|
530 | | - public static Dictionary<UIContext, AppWindow> AppWindows { get; set; } |
531 | | - = new Dictionary<UIContext, AppWindow>(); |
532 | | - |
533 | 529 | private async void ShowProperties() |
534 | 530 | { |
535 | 531 | if (App.CurrentInstance.ContentPage.IsItemSelected) |
@@ -562,27 +558,28 @@ private async Task OpenPropertiesWindow(object item) |
562 | 558 | { |
563 | 559 | if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) |
564 | 560 | { |
565 | | - AppWindow appWindow = await AppWindow.TryCreateAsync(); |
566 | | - Frame frame = new Frame(); |
567 | | - appWindow.TitleBar.ExtendsContentIntoTitleBar = true; |
568 | | - frame.Navigate(typeof(Properties), item, new SuppressNavigationTransitionInfo()); |
569 | | - |
570 | | - WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(400, 550)); |
571 | | - |
572 | | - appWindow.RequestSize(new Size(400, 550)); |
573 | | - appWindow.Title = ResourceController.GetTranslation("PropertiesTitle"); |
| 561 | + CoreApplicationView newWindow = CoreApplication.CreateNewView(); |
| 562 | + ApplicationView newView = null; |
574 | 563 |
|
575 | | - ElementCompositionPreview.SetAppWindowContent(appWindow, frame); |
576 | | - AppWindows.Add(frame.UIContext, appWindow); |
577 | | - |
578 | | - appWindow.Closed += delegate |
| 564 | + await newWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => |
579 | 565 | { |
580 | | - AppWindows.Remove(frame.UIContext); |
581 | | - frame.Content = null; |
582 | | - appWindow = null; |
583 | | - }; |
584 | | - |
585 | | - await appWindow.TryShowAsync(); |
| 566 | + Frame frame = new Frame(); |
| 567 | + frame.Navigate(typeof(Properties), item, new SuppressNavigationTransitionInfo()); |
| 568 | + Window.Current.Content = frame; |
| 569 | + Window.Current.Activate(); |
| 570 | + |
| 571 | + newView = ApplicationView.GetForCurrentView(); |
| 572 | + newWindow.TitleBar.ExtendViewIntoTitleBar = true; |
| 573 | + newView.Title = ResourceController.GetTranslation("PropertiesTitle"); |
| 574 | + newView.SetPreferredMinSize(new Size(400, 550)); |
| 575 | + newView.Consolidated += delegate |
| 576 | + { |
| 577 | + Window.Current.Close(); |
| 578 | + }; |
| 579 | + }); |
| 580 | + bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newView.Id); |
| 581 | + // Set window size again here as sometimes it's not resized in the page Loaded event |
| 582 | + newView.TryResizeView(new Size(400, 550)); |
586 | 583 | } |
587 | 584 | else |
588 | 585 | { |
|
0 commit comments