private async void OKButton_Click(object sender, RoutedEventArgs e) { if (contentFrame.Content is PropertiesGeneral propertiesGeneral) { await propertiesGeneral.SaveChangesAsync(listedItem); } else { if (!await(contentFrame.Content as PropertiesTab).SaveChangesAsync(listedItem)) { return; } } if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { if (WindowDecorationsHelper.IsWindowDecorationsAllowed) { await appWindow.CloseAsync(); } else { await ApplicationView.GetForCurrentView().TryConsolidateAsync(); } } else { propertiesDialog?.Hide(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { AppSettings.ThemeModeChanged -= AppSettings_ThemeModeChanged; if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { await propWindow.CloseAsync(); } else { var propertiesDialog = new PropertiesDialog(); propertiesDialog.Hide(); } }
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { await propWindow.CloseAsync(); } }
protected override async void OnNavigatedFrom(NavigationEventArgs e) { if (appWindow != null) { await appWindow.CloseAsync(); } }
private async void Items_VectorChanged(Windows.Foundation.Collections.IObservableVector <object> sender, Windows.Foundation.Collections.IVectorChangedEventArgs @event) { // If there are no more tabs and we're in a secondary AppWindow, close that Window. if (sender.Count == 0 && RootAppWindow != null) { await RootAppWindow.CloseAsync(); } // TODO: Close the root CoreApplicationView? }
private async void Button_Click(object sender, RoutedEventArgs e) { App.AppSettings.ThemeModeChanged -= AppSettings_ThemeModeChanged; if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { await propWindow.CloseAsync(); } else { App.PropertiesDialogDisplay.Hide(); _tokenSource.Cancel(); _tokenSource.Dispose(); _tokenSource = new CancellationTokenSource(); } }
private async void Tabs_TabItemsChanged(TabView sender, Windows.Foundation.Collections.IVectorChangedEventArgs args) { // If there are no more tabs, close the window. if (sender.TabItems.Count == 0) { if (RootAppWindow != null) { await RootAppWindow.CloseAsync(); } else { Window.Current.Close(); } } }
public async System.Threading.Tasks.Task CloseTab(winui.Controls.TabViewItem tab, bool dispose = true) { if (tab is null) { return; } if (dispose) { //((tab?.Content as Frame)?.Content as BookFixed3Viewer)?.CloseOperation(); ((tab?.Content as Frame)?.Content as IDisposable)?.Dispose(); ((tab?.Content as Frame)?.Content as IDisposableBasic)?.DisposeBasic(); (tab?.Content as Frame)?.Navigate(typeof(Page)); } if (tab.IsClosable) { TabViewMain.TabItems.Remove(tab); } if (TabViewMain.TabItems.Count == 0) { //https://github.com/microsoft/Xaml-Controls-Gallery/blob/master/XamlControlsGallery/TabViewPages/TabViewWindowingSamplePage.xaml.cs //This is far from smartness. But this is in microsoft repo. //There should be a way to detect this is mainwindow or not, but I dont know. if (RootAppWindow != null) { await RootAppWindow.CloseAsync(); } else { try { //I need to close only main window. But error occurs and I have no idea how to fix it... //Closing main window is not allowed. //There is a question but no answer. //https://stackoverflow.com/questions/39944258/closing-main-window-is-not-allowed //Application.Current.Exit(); //Window.Current.Close(); //OpenTabWeb("https://www.google.com/"); } catch (InvalidOperationException) { } } } }
private async void WebView_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args) { if (args.Uri.ToString() == targetUri) { List <HttpCookie> li = filter.CookieManager.GetCookies(new Uri(targetUri)).ToList(); string cookie = ""; for (int i = 0; i <= li.Count - 1; i++) { cookie += li[i]; } Debug.Write(cookie); if (cookie != "") { Method(cookie); await appWindow.CloseAsync(); } } }
private async void ButtonSave_Click(object sender, RoutedEventArgs e) { try { switch (formatFile) { case "doc": SaveDOC_Click(); break; case "docx": SaveDOCX_Click(); break; case "pdf": SavePDF_Click(); break; } await appWindow.CloseAsync(); } catch (Exception) { } }
public static async Task <CompactModeArgs> OpenCompactMode(ContentPage contentPage) { if (!ApiInformation.IsTypePresent("global::Windows.UI.WindowManagement.AppWindow")) { return(new CompactModeArgs(null, false)); } // 1. Create a new Window AppWindow appWindow = await AppWindow.TryCreateAsync(); var frameworkElement = contentPage.CreateFrameworkElement(); global::Windows.UI.Xaml.Controls.Frame frame = new global::Windows.UI.Xaml.Controls.Frame() { Content = frameworkElement }; // 2. Create the pageand set the new window's content ElementCompositionPreview.SetAppWindowContent(appWindow, frame); CompactModeArgs args = null; // 3. Check if you can leverage the compact overlay APIs if (appWindow.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay)) { // 4. Show the window bool result = await appWindow.TryShowAsync(); if (result) { bool windowClosed = false; appWindow.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay); frame.SizeChanged += OnFrameSizeChanged; appWindow.Closed += AppWindow_Closed; args = new CompactModeArgs(async() => { if (windowClosed) { return; } frame.SizeChanged -= OnFrameSizeChanged; await appWindow.CloseAsync(); }, true); void OnFrameSizeChanged(object sender, global::Windows.UI.Xaml.SizeChangedEventArgs e) { if (windowClosed) { return; } contentPage.HeightRequest = frame.ActualWidth; contentPage.WidthRequest = frame.ActualHeight; Layout.LayoutChildIntoBoundingRegion(contentPage, new Rectangle(0, 0, frame.ActualWidth, frame.ActualHeight)); } void AppWindow_Closed(AppWindow sender, AppWindowClosedEventArgs a) { frame.SizeChanged -= OnFrameSizeChanged; windowClosed = true; } } } if (args == null) { args = new CompactModeArgs(null, false); } return(args); }
private async void ConfirmButton_Click(object sender, RoutedEventArgs e) { await Window.CloseAsync(); }
private void OnConsolidated(ApplicationView sender, ApplicationViewConsolidatedEventArgs args) { _newWindow?.CloseAsync(); }
private async void OnCloseClick(object sender, RoutedEventArgs e) => await _appWindow.CloseAsync();
public async Task <bool> CloseWindow(AppWindow window) { await window.CloseAsync(); return(true); }