public static async Task <bool> TryShowWindowAsync(EbookViewModel ebookViewModel) { if (App.ReadingWindows.Keys.Any(rw => rw.Isbn == ebookViewModel.Isbn)) { return(await App.ReadingWindows[App.ReadingWindows.Keys.First(evm => evm.Isbn == ebookViewModel.Isbn)].TryShowAsync()); } AppWindow readingWindow = await AppWindow.TryCreateAsync(); App.ReadingWindows.Add(ebookViewModel, readingWindow); readingWindow.Title = ebookViewModel.Title; readingWindow.Closed += (sender, e) => { App.ReadingWindows.Remove(App.ReadingWindows.First(_ => _.Value == sender).Key); }; Frame readingWindowContentFrame = new Frame(); readingWindowContentFrame.Navigate(typeof(ReadingPage), ebookViewModel); ElementCompositionPreview.SetAppWindowContent(readingWindow, readingWindowContentFrame); return(await readingWindow.TryShowAsync()); }
private async void CreateSecondScreen() { // Create a new window. AppWindow appWindow = await AppWindow.TryCreateAsync(); // Create a Frame and navigate to the Page you want to show in the new window. Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(AppWindowPage)); // Attach the XAML content to the window. ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); // Add the new page to the Dictionary using the UIContext as the Key. AppWindows.Add(appWindowContentFrame.UIContext, appWindow); appWindow.Title = "App Window " + AppWindows.Count.ToString(); // When the window is closed, be sure to release // XAML resources and the reference to the window. appWindow.Closed += delegate { MainPage.AppWindows.Remove(appWindowContentFrame.UIContext); appWindowContentFrame.Content = null; appWindow = null; }; // Show the window. await appWindow.TryShowAsync(); }
public async Task <bool> ShowWindow(Type type, ToggleButton toggleButton) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); frame.Navigate(type, this); ElementCompositionPreview.SetAppWindowContent(appWindow, frame); UIContext uIContext = frame.UIContext; appWindows.Add(uIContext, appWindow); appWindow.Closed += delegate { MainPage.appWindows.Remove(uIContext); frame.Content = null; appWindow = null; toggleButton.IsChecked = false; }; try { Debug.WriteLine("Is de Nuget Pakage"); await appWindow.TryShowAsync(); } catch (Exception exception) { Debug.WriteLine("Exeption in ShowWindow"); Debug.WriteLine(exception.Message); } return(true); }
// todo: work out a huge mem leak, the windowContent is still running even when we destroy the appWindow ???? // i.e. the mediaPlayerElement is still running , i can here the media playing public static async void OpenWindow(UIElement windowContent, double width, double height, Action finishedOpeningAction) { AppWindow appWindow = await AppWindow.TryCreateAsync(); appWindow.Title = "desktopxx"; appWindow.RequestSize(new Size(width, height)); Grid appWindowRootGrid = new Grid(); appWindowRootGrid.Children.Add(windowContent); ElementCompositionPreview.SetAppWindowContent(appWindow, windowContent); appWindow.Closed += (a, o) => { appWindowRootGrid.Children.Remove(windowContent); appWindowRootGrid = null; windowContent = null; appWindow = null; }; await appWindow.TryShowAsync(); finishedOpeningAction?.Invoke(); //DesktopHelper.SendWindowToBackground("desktopxx"); }
private async void ShowNewAppWindow_Click(object sender, RoutedEventArgs e) { // Only ever create and show one window. If the AppWindow exists call TryShow on it to bring it to foreground. if (appWindow == null) { // Create a new window appWindow = await AppWindow.TryCreateAsync(); // Navigate our frame to the page we want to show in the new window appWindowFrame.Navigate(typeof(AppWindowMainPage)); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); // Set up event handlers for the window // This is not really needed for this demo, but I mention this in the blogpost so it's here for reference. RegisterEventHandlersForWindow(appWindow); // Let's make this new window 500x500, just to show that the new window doesn't have to be of the same size as the main app window appWindow.RequestSize(new Windows.Foundation.Size(500, 500)); // Show the window appWindow.TryShowAsync(); } else { appWindow.TryShowAsync(); } }
private async void LibraryProperties_Click(object sender, RoutedEventArgs e) { if (LibraryGrid.SelectedItem is LibraryFolder Library) { if (await FileSystemStorageItemBase.CreateFromStorageItemAsync(Library.Folder) is FileSystemStorageFolder Folder) { await Folder.LoadMorePropertiesAsync(); AppWindow NewWindow = await AppWindow.TryCreateAsync(); NewWindow.RequestSize(new Size(420, 600)); NewWindow.RequestMoveRelativeToCurrentViewContent(new Point(Window.Current.Bounds.Width / 2 - 200, Window.Current.Bounds.Height / 2 - 300)); NewWindow.PersistedStateId = "Properties"; NewWindow.Title = Globalization.GetString("Properties_Window_Title"); NewWindow.TitleBar.ExtendsContentIntoTitleBar = true; NewWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; NewWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; ElementCompositionPreview.SetAppWindowContent(NewWindow, new PropertyBase(NewWindow, Folder)); WindowManagementPreview.SetPreferredMinSize(NewWindow, new Size(420, 600)); await NewWindow.TryShowAsync(); } } }
private async void NewWindowButton_Click(object sender, RoutedEventArgs e) { //CoreApplicationView newView = CoreApplication.CreateNewView(); //int newViewId = 0; //await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => //{ // Frame frame = new Frame(); // frame.Navigate(typeof(InstancePage), null); // Window.Current.Content = frame; // // You have to activate the window in order to show it later. // Window.Current.Activate(); // newViewId = ApplicationView.GetForCurrentView().Id; //}); //bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(InstancePage)); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); await appWindow.TryShowAsync(); appWindow.Closed += delegate { appWindowContentFrame.Content = null; appWindow = null; }; }
public async void ToPage() { appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(RecentList), RecognizerViewModel); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); appWindow.RequestSize(new Size(500, 900)); await appWindow.TryShowAsync(); //this.mainPage.IsEnabled = false; appWindow.Closed += delegate { // //Task.Delay(1000); // dictationTextBox.Text = ""; // appWindowContentFrame.Content = null; // appWindow = null; //this.mainPage.IsEnabled = true; // recentFile = RecentList.openFile; // RecentList.openFile = null; // OpenFileDialog_Click(null, null); // }; }
private async void Button_Click(object sender, RoutedEventArgs e) { showWindowBtn.IsEnabled = false; // Only ever create and show one window. If the AppWindow exists call TryShow on it to bring it to foreground. 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; }; // 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); } // Get DisplayRegion to position our window on DisplayRegion secondaryDisplayRegion = GetOtherDisplayRegion(ApplicationView.GetForCurrentView().GetDisplayRegions()[0]); if (secondaryDisplayRegion != null) { appWindow.RequestMoveToDisplayRegion(secondaryDisplayRegion); } // If the window is not visible, show it and/or bring it to foreground if (!appWindow.IsVisible) { await appWindow.TryShowAsync(); } showWindowBtn.IsEnabled = true; }
private async void AppBarButton_Click_3(object sender, RoutedEventArgs e) { try { StoreServicesCustomEventLogger logger = StoreServicesCustomEventLogger.GetDefault(); logger.Log("ChartEvent"); blankPagePlot = new BlankPagePlot(); appWindow = await AppWindow.TryCreateAsync(); ElementCompositionPreview.SetAppWindowContent(appWindow, blankPagePlot); v = await appWindow.TryShowAsync(); if (v) { blankPagePlot.iniPlot(device.namea); blankPagePlot.PlotModel.addSeries(); Size size = new Size() { Height = 100, Width = 100 }; appWindow.RequestSize(size); appWindow.Closed += delegate { v = false; blankPagePlot = null; appWindow = null; }; } } catch (Exception) { } }
private async void ShowProperties(object parameter) { if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); appWindow.TitleBar.ExtendsContentIntoTitleBar = true; frame.Navigate(typeof(Properties), null, new SuppressNavigationTransitionInfo()); WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(400, 475)); appWindow.RequestSize(new Size(400, 475)); appWindow.Title = ResourceController.GetTranslation("PropertiesTitle"); ElementCompositionPreview.SetAppWindowContent(appWindow, frame); AppWindows.Add(frame.UIContext, appWindow); appWindow.Closed += delegate { AppWindows.Remove(frame.UIContext); frame.Content = null; appWindow = null; }; await appWindow.TryShowAsync(); } else { App.PropertiesDialogDisplay.propertiesFrame.Tag = App.PropertiesDialogDisplay; App.PropertiesDialogDisplay.propertiesFrame.Navigate(typeof(Properties), parameter, new SuppressNavigationTransitionInfo()); await App.PropertiesDialogDisplay.ShowAsync(ContentDialogPlacement.Popup); } }
private async Task CreateChildWindowAsync() { _newWindow = await AppWindow.TryCreateAsync(); _newWindow.RequestSize(new Size(200, 200)); _newWindow.RequestMoveAdjacentToCurrentView(); _newWindow.Frame.SetFrameStyle(AppWindowFrameStyle.NoFrame); _newWindow.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay); await _newWindow.TryShowAsync(); }
private async void OpenEditDialog() { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindow.Title = "Marker Infocard Window"; appWindow.RequestSize(new Size(200, 250)); appWindowContentFrame.Navigate(typeof(EditPage), SelectedLocation); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); await appWindow.TryShowAsync(); }
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; }
private async void Recent_Click(object sender, RoutedEventArgs e) { List <StorageFile> files = new List <StorageFile>(); var mru = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; //StorageFile retrievedFile = await mru.GetFileAsync(token); foreach (Windows.Storage.AccessCache.AccessListEntry entry in mru.Entries) { string mruToken = entry.Token; string mruMetadata = entry.Metadata; try { Windows.Storage.IStorageItem item = await mru.GetItemAsync(mruToken); if (item is StorageFile) { //StorageFile item = await mru.GetFileAsync(mruToken); files.Add((StorageFile)item); } } catch (FileNotFoundException) {} } appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(RecentList), RecognizerViewModel); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); appWindow.RequestSize(new Size(500, 900)); await appWindow.TryShowAsync(); this.mainPage.IsEnabled = false; appWindow.Closed += delegate { // //Task.Delay(1000); // dictationTextBox.Text = ""; // appWindowContentFrame.Content = null; // appWindow = null; this.mainPage.IsEnabled = true; // recentFile = RecentList.openFile; // RecentList.openFile = null; // OpenFileDialog_Click(null, null); // }; }
// Create a new Window once the Tab is dragged outside. private async void Tabs_TabDroppedOutside(TabView sender, TabViewTabDroppedOutsideEventArgs args) { AppWindow newWindow = await AppWindow.TryCreateAsync(); var newPage = new TabViewWindowingSamplePage(); newPage.SetupWindow(newWindow); ElementCompositionPreview.SetAppWindowContent(newWindow, newPage); Tabs.TabItems.Remove(args.Tab); newPage.AddTabToTabs(args.Tab); await newWindow.TryShowAsync(); }
private async void Compact_Click(object sender, RoutedEventArgs e) { if (_window == null) { OnBackRequestedOverride(this, new HandledRoutedEventArgs()); // Create a new AppWindow _window = await AppWindow.TryCreateAsync(); // Make sure we release the reference to this window, and release XAML resources, when it's closed _window.Closed += delegate { _window = null; _surface.NavigateToString(string.Empty); }; // Is CompactOverlay supported for this AppWindow? If not, then stop. if (_window.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay)) { // Create a new frame for the window // Navigate the frame to the CompactOverlay page inside it. //appWindowFrame.Navigate(typeof(SecondaryAppWindowPage)); // Attach the frame to the window Presenter.Child = new Border(); var w = Math.Max(_webPage.EmbedWidth, 340); var h = Math.Max(_webPage.EmbedHeight, 200); double ratioX = (double)340 / w; double ratioY = (double)340 / h; double ratio = Math.Min(ratioX, ratioY); ElementCompositionPreview.SetAppWindowContent(_window, _surface); // Let's set the title so that we can tell the windows apart _window.Title = _webPage.Title; _window.TitleBar.ExtendsContentIntoTitleBar = true; _window.RequestSize(new Size(w * ratio, h * ratio)); // Request the Presentation of the window to CompactOverlay var switched = _window.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay); if (switched) { // If the request was satisfied, show the window await _window.TryShowAsync(); } } } else { await _window.TryShowAsync(); } }
private async void OpenNewWindow(Type pageToOpen) { AppWindow window = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); frame.Navigate(pageToOpen); ElementCompositionPreview.SetAppWindowContent(window, frame); await window.TryShowAsync(); window.Closed += delegate { frame.Content = null; window = null; }; }
private async void createTestSampleWindow() { if (TestSampleWindow == null) { // ※補足 playerDataFrame.Navigate() -> PlayerDataのコンテンツを持ってくるメソッド // ElementCompositionPreview.SetAppWindowContent() -> Windowにコンテンツを設置するメソッド // playerDataWindow.Closed += delegate -> ウィンドウが閉まった時にウィンドウにあるコンテンツインスタンスを消すメソッド TestSampleWindow = await AppWindow.TryCreateAsync(); Frame TestSampleFrame = new Frame(); TestSampleFrame.Navigate(typeof(testsample)); ElementCompositionPreview.SetAppWindowContent(TestSampleWindow, TestSampleFrame); await TestSampleWindow.TryShowAsync(); TestSampleWindow.Closed += delegate { TestSampleFrame.Content = null; TestSampleWindow = null; }; } else { Frame TestSampleFrame = new Frame(); TestSampleFrame.Navigate(typeof(testsample)); ElementCompositionPreview.SetAppWindowContent(TestSampleWindow, TestSampleFrame); await TestSampleWindow.TryShowAsync(); TestSampleWindow.Closed += delegate { TestSampleFrame.Content = null; TestSampleWindow = null; }; } }
private async void ShowWindowBtn_Click(object sender, RoutedEventArgs e) { // Clear any previous message. MainPage.Current.NotifyUser(string.Empty, NotifyType.StatusMessage); Double.TryParse(windowWidthTxt.Text, out var windowWidth); Double.TryParse(windowHeightTxt.Text, out var windowHeight); if (windowWidth < MinWindowWidth || windowHeight < MinWindowHeight) { MainPage.Current.NotifyUser($"Please specify a width of at least {MinWindowWidth} and a height of at least {MinWindowHeight}.", NotifyType.ErrorMessage); return; } showWindowBtn.IsEnabled = false; // Only ever create and show one window. If the AppWindow exists use it 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; }; // Navigate the frame to the page we want to show in the new window appWindowFrame.Navigate(typeof(SecondaryAppWindowPage)); } // If specified size is smaller than the default min size for a window we need to set a new preferred min size first. // Let's set it to the smallest allowed and leave it at that. if (windowWidth < 500 || windowHeight < 320) { WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(MinWindowWidth, MinWindowHeight)); } // Request the size of our window appWindow.RequestSize(new Size(windowWidth, windowHeight)); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); // If the window is not visible, show it and/or bring it to foreground if (!appWindow.IsVisible) { await appWindow.TryShowAsync(); } showWindowBtn.IsEnabled = true; }
private async void ShowNewWindow(object sender, RoutedEventArgs e, Człowiek osoba) { // Create a new window appWindow = await AppWindow.TryCreateAsync(); // Navigate our frame to the page we want to show in the new window appWindowFrame.Navigate(typeof(Sczegoly), osoba); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); // Show the window appWindow.Closed += delegate { appWindowFrame.Content = null; appWindow = null; }; await appWindow.TryShowAsync(); }
private async void ShowWindowBtn_Click(object sender, RoutedEventArgs e) { // Is CompactOverlay supported for our main window? // If so, it will be supported for a new window as well. // If it isn't, it will not be supported for new windows either so we cannot proceed. if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay)) { return; } showWindowBtn.IsEnabled = false; if (appWindow == null) { // Create a new AppWindow 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; }; // Is CompactOverlay supported for this AppWindow? If not, then stop. if (appWindow.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay)) { // Create a new frame for the window // Navigate the frame to the CompactOverlay page inside it. appWindowFrame.Navigate(typeof(SecondaryAppWindowPage)); // Attach the frame to the window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); // Let's set the title so that we can tell the windows apart appWindow.Title = "CompactOverlay Window"; // Request the Presentation of the window to CompactOverlay bool switched = appWindow.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay); if (switched) { // If the request was satisfied, show the window await appWindow.TryShowAsync(); } } } else { await appWindow.TryShowAsync(); } showWindowBtn.IsEnabled = true; }
// Create a new Window once the Tab is dragged outside. private async void Tabs_TabDroppedOutside(TabView sender, TabViewTabDroppedOutsideEventArgs args) { AppWindow newWindow = await AppWindow.TryCreateAsync(); var newPage = new MainPage(); newPage.SetupWindow(newWindow); ElementCompositionPreview.SetAppWindowContent(newWindow, newPage); Tabs.TabItems.Remove(args.Tab); newPage.AddTabToTabs(args.Tab); // TODO: Remove when TabView.TabItems.VectorChagned is exposed. sender.Tag = newWindow; await newWindow.TryShowAsync(); }
private async void HyperlinkButton_Click(object sender, RoutedEventArgs e) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(AddConversationPage)); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); await appWindow.TryShowAsync(); appWindow.Closed += delegate { appWindowContentFrame.Content = null; appWindow = null; ViewModel.AppWindow = null; }; ViewModel.AppWindow = appWindow; }
private async void _MenuItem_ReferencePicture_Click(object sender, RoutedEventArgs e) { FileOpenPicker fileOpenPicker1 = new FileOpenPicker(); fileOpenPicker1.FileTypeFilter.Add(".bmp"); fileOpenPicker1.FileTypeFilter.Add(".jpg"); fileOpenPicker1.FileTypeFilter.Add(".jpeg"); fileOpenPicker1.FileTypeFilter.Add(".png"); fileOpenPicker1.FileTypeFilter.Add(".gif"); fileOpenPicker1.FileTypeFilter.Add(".tif"); StorageFile file = await fileOpenPicker1.PickSingleFileAsync(); if (file == null) { return; } AppWindow referencePicture = await AppWindow.TryCreateAsync(); Image imageControl = new Image(); var img1 = new BitmapImage(); try { await img1.SetSourceAsync(await file.OpenReadAsync()); imageControl.Source = img1; ElementCompositionPreview.SetAppWindowContent(referencePicture, imageControl); if (referencePicture.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay)) { referencePicture.Title = "参考图片"; if (referencePicture.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay)) { referencePicture.RequestSize(new Size(img1.PixelWidth, img1.PixelHeight)); await referencePicture.TryShowAsync(); img1.Play(); } } } catch { } }
private async void Attribute_Click(object sender, RoutedEventArgs e) { if (SearchResultList.SelectedItem is FileSystemStorageItemBase Item) { AppWindow NewWindow = await AppWindow.TryCreateAsync(); NewWindow.RequestSize(new Size(420, 600)); NewWindow.RequestMoveRelativeToCurrentViewContent(new Point(Window.Current.Bounds.Width / 2 - 200, Window.Current.Bounds.Height / 2 - 300)); NewWindow.PersistedStateId = "Properties"; NewWindow.Title = Globalization.GetString("Properties_Window_Title"); NewWindow.TitleBar.ExtendsContentIntoTitleBar = true; NewWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; NewWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; ElementCompositionPreview.SetAppWindowContent(NewWindow, new PropertyBase(NewWindow, Item)); WindowManagementPreview.SetPreferredMinSize(NewWindow, new Size(420, 600)); await NewWindow.TryShowAsync(); } }
private async void AppWindow_Launch(object sender, RoutedEventArgs e) { AppWin = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(BlankPage2)); ElementCompositionPreview.SetAppWindowContent(AppWin, appWindowContentFrame); AppWindows.Add(appWindowContentFrame.UIContext, AppWin); AppWin.Title = "App Window " + AppWindows.Count.ToString(); AppWin.Closed += delegate { MainPage.AppWindows.Remove(appWindowContentFrame.UIContext); appWindowContentFrame.Content = null; AppWin = null; }; await AppWin.TryShowAsync(); }
public async Task ShowWebView(int width, int height) { appWindow = await AppWindow.TryCreateAsync(); webView.Width = width; webView.Height = height; appWindow.RequestSize(new Windows.Foundation.Size(width, height)); ElementCompositionPreview.SetAppWindowContent(appWindow, webView); httpRequestMessage.Method = HttpMethod.Get; httpRequestMessage.RequestUri = new Uri(loginUri); appWindow.Closed += delegate { appWindow = null; httpRequestMessage.Dispose(); filter.Dispose(); webView.Stop(); }; webView.NavigateWithHttpRequestMessage(httpRequestMessage); await appWindow.TryShowAsync(); }
// Obtain from MS docs // https://docs.microsoft.com/en-us/windows/uwp/design/layout/app-window private async void NewWindow(String Title, Type Page) { appWindow = await AppWindow.TryCreateAsync(); appWindow.Title = Title; Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(Page); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); AppWindows.Add(appWindowContentFrame.UIContext, appWindow); appWindow.Closed += delegate { MainPage.AppWindows.Remove(appWindowContentFrame.UIContext); appWindowContentFrame.Content = null; appWindow = null; }; await appWindow.TryShowAsync(); }
public async Task<bool> TryCreateNewWindowAsync(TabViewViewModel tabView, Size size) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); frame.Navigate(typeof(AppWindowPage), new TabViewNavigationParameters(tabView, appWindow)); ElementCompositionPreview.SetAppWindowContent(appWindow, frame); WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(MinWindowWidth, MinWindowHeight)); appWindow.RequestSize(size); appWindow.TitleBar.ExtendsContentIntoTitleBar = true; appWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; appWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; appWindow.RequestMoveAdjacentToCurrentView(); bool success = await appWindow.TryShowAsync(); return success; }