private void TabViewTabDroppedOutside(object sender, Microsoft.UI.Xaml.Controls.TabViewTabDroppedOutsideEventArgs e) { TabViewItem tab = e.Tab; if (tab != null) { TabDroppedOutsideTextBlock.Text = tab.Header.ToString(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is Tuple <TabViewItem, Frame> Parameters) { Nav = Parameters.Item2; TabItem = Parameters.Item1; TabItem.Header = Globalization.GetString("MainPage_PageDictionary_ThisPC_Label"); } }
public void GetToolTipStringForTab(TabViewItem item, TextBlock textBlock) { var tooltip = ToolTipService.GetToolTip(item); if (tooltip is ToolTip) { textBlock.Text = (tooltip as ToolTip).Content.ToString(); } else { textBlock.Text = tooltip.ToString(); } }
public void AddButtonClick(object sender, object e) { if (Tabs != null) { TabViewItem item = new TabViewItem(); item.IconSource = _iconSource; item.Header = "New Tab " + _newTabNumber; item.Content = item.Header; Tabs.TabItems.Add(item); _newTabNumber++; } }
public void AddButtonClick(object sender, object e) { if (Tabs != null) { TabViewItem item = new TabViewItem(); item.Icon = new SymbolIcon(Symbol.Calendar); item.Header = "New Tab " + _newTabNumber; item.Content = item.Header; item.SetValue(AutomationProperties.NameProperty, item.Header); Tabs.Items.Add(item); _newTabNumber++; } }
private void Page_Loaded(object sender, RoutedEventArgs e) { var newTab = new Microsoft.UI.Xaml.Controls.TabViewItem(); newTab.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document }; newTab.Header = "Blank Page"; Frame frame = new Frame(); newTab.Content = frame; frame.Navigate(typeof(BlankPage1), newTab); tabView.TabItems.Add(newTab); }
private void tabView_AddTabButtonClick(Microsoft.UI.Xaml.Controls.TabView sender, object args) { var newTab = new Microsoft.UI.Xaml.Controls.TabViewItem(); newTab.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document }; newTab.Header = "Blank Page"; Frame frame = new Frame(); newTab.Content = frame; frame.Navigate(typeof(BlankWEBPage), newTab); sender.TabItems.Add(newTab); }
public (Frame, winui.Controls.TabViewItem) OpenTab(string titleId) { var newTab = new winui.Controls.TabViewItem(); var titleString = Helper.UIHelper.GetTitleByResource(titleId); newTab.Header = String.IsNullOrWhiteSpace(titleString) ? "New Tab" : titleString; Frame frame = new Frame(); newTab.Content = frame; tabView.TabItems.Add(newTab); tabView.SelectedIndex = tabView.TabItems.Count - 1; return(frame, newTab); }
public async void CloseTab(winui.Controls.TabViewItem tab) { if (tab == null) { return; } ((tab?.Content as Frame)?.Content as BookFixed3Viewer)?.SaveInfo(); if (tab.IsClosable) { tabView.TabItems.Remove(tab); } if (tabView.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 to how 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 (System.InvalidOperationException) { } } } }
/* * Ensure that the path bar gets updated for user interaction * whenever the path changes. We will get the individual directories from * the updated, most-current path and add them to the UI. */ private void Universal_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { // Clear the path UI GetCurrentSelectedTabInstance <ProHome>().accessiblePathTabView.Items.Clear(); Style tabStyleFixed = GetCurrentSelectedTabInstance <ProHome>().accessiblePathTabView.Resources["PathSectionTabStyle"] as Style; FontWeight weight = new FontWeight() { Weight = FontWeights.SemiBold.Weight }; List <string> pathComponents = new List <string>(); if (e.PropertyName == "path") { // If path is a library, simplify it // If path is found to not be a library pathComponents = Universal.path.Split("\\", StringSplitOptions.RemoveEmptyEntries).ToList(); int index = 0; foreach (string s in pathComponents) { string componentLabel = null; string tag = ""; if (s.Contains(":")) { if (s == @"C:" || s == @"c:") { componentLabel = @"Local Disk (C:\)"; } else { componentLabel = @"Drive (" + s + @"\)"; } tag = s + @"\"; Microsoft.UI.Xaml.Controls.TabViewItem item = new Microsoft.UI.Xaml.Controls.TabViewItem() { Header = componentLabel + " ›", Tag = tag, CornerRadius = new CornerRadius(0), Style = tabStyleFixed, FontWeight = weight, FontSize = 14 }; item.Tapped += Item_Tapped; GetCurrentSelectedTabInstance <ProHome>().accessiblePathTabView.Items.Add(item); } else { componentLabel = s; foreach (string part in pathComponents.GetRange(0, index + 1)) { tag = tag + part + @"\"; } Microsoft.UI.Xaml.Controls.TabViewItem item = new Microsoft.UI.Xaml.Controls.TabViewItem() { Header = componentLabel + " ›", Tag = tag, CornerRadius = new CornerRadius(0), Style = tabStyleFixed, FontWeight = weight, FontSize = 14 }; item.Tapped += Item_Tapped; GetCurrentSelectedTabInstance <ProHome>().accessiblePathTabView.Items.Add(item); } index++; } } }