private async void ShowWindowBtn_Click(object sender, RoutedEventArgs e) { // Clear any previous message. MainPage.Current.NotifyUser(string.Empty, NotifyType.StatusMessage); if (!Double.TryParse(windowOffsetXTxt.Text, out var horizontalOffset) || !Double.TryParse(windowOffsetYTxt.Text, out var verticalOffset)) { MainPage.Current.NotifyUser($"Please specify valid numeric offsets.", NotifyType.ErrorMessage); return; } showWindowBtn.IsEnabled = false; // Only ever create and show one window. if (appWindow == null) { // Create a new window appWindow = await AppWindow.TryCreateAsync(); // Make sure we release the reference to this window, and release XAML resources, when it's closed appWindow.Closed += delegate { appWindow = null; appWindowFrame.Content = null; }; // Request the size of our window appWindow.RequestSize(new Size(500, 320)); // Navigate the frame to the page we want to show in the new window appWindowFrame.Navigate(typeof(SecondaryAppWindowPage)); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); } // Make a point for our offset. Point offset = new Point(horizontalOffset, verticalOffset); // Check if we should be setting our position relative to ApplicationView or DisplayRegion if (positionOffsetDisplayRegionRB.IsChecked.Value) { // Request an offset relative to the DisplayRegion we're on appWindow.RequestMoveRelativeToDisplayRegion(ApplicationView.GetForCurrentView().GetDisplayRegions()[0], offset); } else { // Relative to our ApplicationView appWindow.RequestMoveRelativeToCurrentViewContent(offset); } // If the window is not visible, show it and/or bring it to foreground if (!appWindow.IsVisible) { await appWindow.TryShowAsync(); } showWindowBtn.IsEnabled = true; }