private async void Settings_Click(object sender, RoutedEventArgs e) { appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(Settings), RecognizerViewModel); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); appWindow.RequestSize(new Size(500, 900)); await appWindow.TryShowAsync(); this.mainPage.IsEnabled = false; appWindow.Closed += delegate { appWindowContentFrame.Content = null; appWindow = null; this.mainPage.IsEnabled = true; }; //CoreApplicationView newView = CoreApplication.CreateNewView(); //int newViewId = 0; //await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => //{ // Frame frame = new Frame(); // frame.Navigate(typeof(settings), RecognizerViewModel); // Window.Current.Content = frame; // Window.Current.Activate(); // newViewId = ApplicationView.GetForCurrentView().Id; //}); //bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); }
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; }; }
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(); }
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); } }
// 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(); } }
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 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(); } } }
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); }
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 SaveAs_Click(object sender, RoutedEventArgs e) { appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(SaveAs), dictationTextBox.Text); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); appWindow.RequestSize(new Size(640, 545)); //bool switched = appWindow.TitleBar.is //.Presenter.RequestPresentation(AppWindowPresentationKind.FullScreen); //if (switched) //{ // appWindow.RequestSize(new Size(640, 545)); // // If the request was satisfied, show the window // await appWindow.TryShowAsync(); //} await appWindow.TryShowAsync(); //this.mainPage.IsEnabled = false; appWindow.Closed += delegate { appWindowContentFrame.Content = null; appWindow = null; this.mainPage.IsEnabled = true; }; }
private Task <bool> ShowWindow(Type viewType, MvxWindowPresentationAttribute attribute, MvxViewModelRequest request) { try { return(Task.Run(async() => { var requestText = GetRequestText(request); var viewsContainer = Mvx.IoCProvider.Resolve <IMvxViewsContainer>(); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() => { var appWindow = await AppWindow.TryCreateAsync(); var appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(viewType, requestText); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); await appWindow.TryShowAsync(); HandleBackButtonVisibility(); }); return true; })); } catch (Exception exception) { return(Task.FromResult(false)); } }
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 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 Pierwszy_Click_Button(object sender, RoutedEventArgs e) { Frame appWindowFrame = new Frame(); AppWindow appWindow; appWindow = await AppWindow.TryCreateAsync(); //tworze okenko appWindowFrame.Navigate(typeof(SecendWindow)); // nawiguje do okna ktore chce wyswietlic ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); // podpinam xamla await appWindow.TryShowAsync(); //uruchamiam okienko }
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(); } }
public override async Task <WindowHandle> OpenChannelWindowAsync(DiscordChannel channel, WindowHandle currentWindow = null) { if (!Supported) { return(null); } if (await ActivateOtherWindowAsync(channel, currentWindow)) { return(null); } Analytics.TrackEvent("AppWindowWindowingService_OpenChannelWindowAsync"); var window = await AppWindow.TryCreateAsync(); window.RequestMoveRelativeToCurrentViewContent(new Point(276, 0)); window.RequestSize(new Size(Window.Current.Bounds.Width - 276, Window.Current.Bounds.Height)); window.Title = NotificationUtils.GetChannelHeaderName(channel); var frame = new Frame(); frame.Navigate(typeof(MainPage), new MainPageArgs() { ChannelId = channel.Id, FullFrame = true }); ElementCompositionPreview.SetAppWindowContent(window, frame); var frame2 = ElementCompositionPreview.GetAppWindowContent(window); await window.TryShowAsync(); var handle = (AppWindowHandle)CreateOrUpdateHandle(frame, window); window.Closed += (o, e) => { _uiContextDictionary.TryRemove(handle.Context, out _); _windowChannelDictionary.TryRemove(handle, out _); handle = null; frame.Content = null; window = null; }; HandleTitleBarForWindow(null, frame); return(handle); }
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; }; } }
/* -- Method Header Comment * Name : ViewLeaderboard * Purpose : Displays the Leaderboard on a new window * Inputs : None * Outputs : The Leaderboard in a new window * Returns : None */ private static async void ViewLeaderboard() { var leaderboardWindow = await AppWindow.TryCreateAsync(); var appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(Leaderboard)); ElementCompositionPreview.SetAppWindowContent(leaderboardWindow, appWindowContentFrame); await leaderboardWindow.TryShowAsync(); leaderboardWindow.Closed += delegate { appWindowContentFrame.Content = null; leaderboardWindow = 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; }
async void showNewWindow() { // Create a new window var appWindow = await AppWindow.TryCreateAsync(); // Navigate our frame to the page we want to show in the new window //var appWindowFrame = new Frame(); //appWindowFrame.Navigate(typeof(AppWindowMainPage)); Button saveBtn = new Button(); saveBtn.Content = "Save screenshot"; saveBtn.Click += SaveBtn_Click; // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, saveBtn); // Show the window await appWindow.TryShowAsync(); }
// 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(); }