/// <summary> /// Adds a tab to the tab control that contains the settings page. /// </summary> private void AddSettingsTab() { // New tab var settingsTab = new muxc.TabViewItem(); // Name the header "Settings" settingsTab.Header = "Settings"; // name the tab settingsTab.Name = "settingsTab"; // Change the tab icon. settingsTab.IconSource = new muxc.SymbolIconSource() { Symbol = Symbol.Setting }; // Create a frame instance Frame frame = new Frame(); // Add the frame to the tab settingsTab.Content = frame; // Navigate the frame to the settings page. frame.Navigate(typeof(SettingsPage)); // Add the tab to the tab control. TabControl.TabItems.Add(settingsTab); // Set the newly created tab as the selected tab. TabControl.SelectedItem = settingsTab; }
private void AddNewTab(Uri Url) { var newTab = new muxc.TabViewItem(); newTab.IconSource = new muxc.SymbolIconSource() { Symbol = Symbol.Document }; newTab.Header = "New Tab"; WebView webView = new WebView(); webView.IsRightTapEnabled = true; newTab.Content = webView; webView.Navigate(Url); TabControl.TabItems.Add(newTab); TabControl.SelectedItem = newTab; webView.NavigationCompleted += BrowserNaviagted; webView.NewWindowRequested += NewWindowRequested; currentSelectedTab = newTab; currentSelectedWebView = webView; }
/// <summary> /// Navigate the webBrowser home. /// </summary> private async void GetHome() { // Try navigate home try { DataTransfer dt = new DataTransfer(); homeName = await dt.GetHomeAttribute("name"); homeUrl = await dt.GetHomeAttribute("url"); } catch (Exception ex) { // Show a error message if there is an issue. MessageDialog msg = new MessageDialog(ex.Message); await msg.ShowAsync(); } // See if the homeUrl and homeName are not null. if (!string.IsNullOrEmpty(homeUrl) || !string.IsNullOrEmpty(homeName)) { // Naviaget home if they aren't. NavigateHome(); } currentSelectedTab = defaultTab; currentSelectedWebView = webBrowser; }
private void TabControl_TabCloseRequested(muxc.TabView sender, muxc.TabViewTabCloseRequestedEventArgs args) { sender.TabItems.Remove(args.Tab); currentSelectedTab = null; currentSelectedWebView = null; if (args.Tab.Name == "settingsTab") { settingTabCount = 0; } }
private void TabViewControl_AddTabButtonClick(muxc.TabView sender, object args) { var newTab = new muxc.TabViewItem(); newTab.Header = "Nowe SVG"; Frame newFrame = new Frame(); newTab.Content = newFrame; newFrame.Navigate(typeof(NavPage)); sender.TabItems.Add(newTab); TabViewControl.SelectedItem = newTab; }
private void TabView_AddTabButtonClick(MUXC.TabView sender, object args) { var newTab = new MUXC.TabViewItem(); newTab.IconSource = new MUXC.SymbolIconSource() { Symbol = Symbol.Document }; newTab.Header = "New Document"; // The Content of a TabViewItem is often a frame which hosts a page. sender.TabItems.Add(newTab); }
TabViewItem CreateNewTab(TabViewItemDataTemplate _i) { TabViewItem newItem = new TabViewItem { Header = _i.Header, Content = _i.Content, IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = _i.Symbol }, IsClosable = false }; return(newItem); }
//创建一个新tab。 private muxc.TabViewItem createTabViewItem(CodeEditSessionInfo session) { var newTab = new muxc.TabViewItem() { Header = "与" + session.Contact.DisplayName + "聊天中的代码", IsClosable = true, IconSource = new muxc.SymbolIconSource() { Symbol = Symbol.Document }, Content = "", Tag = session }; return(newTab); }
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 Microsoft.UI.Xaml.Controls.TabViewItem CreateDefaultTab() { Frame frame = new Frame(); frame.Navigate(typeof(MainPage)); var tabViewItem = new Microsoft.UI.Xaml.Controls.TabViewItem { Header = "Home", IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource { Symbol = Symbol.Home }, Content = frame, }; return(tabViewItem); }
public (Frame, winui.Controls.TabViewItem) OpenTab(string titleId) { var newTab = new winui.Controls.TabViewItem(); var titleString = UIHelper.GetTitleByResource(titleId); newTab.Header = string.IsNullOrWhiteSpace(titleString) ? "New Tab" : titleString; Frame frame = new(); newTab.Content = frame; TabViewMain.TabItems.Add(newTab); TabViewMain.SelectedItem = newTab; frame.Focus(FocusState.Programmatic); return(frame, newTab); }
private void TabView_AddTabButtonClick(muxc.TabView sender, object args) { var newTab = new muxc.TabViewItem(); newTab.IconSource = new muxc.SymbolIconSource() { Symbol = Symbol.Document }; newTab.Header = "Explore"; // The Content of a TabViewItem is often a frame which hosts a page. Frame frame = new Frame(); newTab.Content = frame; frame.Navigate(typeof(Page)); sender.TabItems.Add(newTab); }
private TabViewItem CreateNewTab(string url) { var newTab = new muxc.TabViewItem(); newTab.IconSource = new muxc.SymbolIconSource() { Symbol = Symbol.Document }; newTab.Header = "New Document"; // The Content of a TabViewItem is often a frame which hosts a page. Frame frame = new Frame(); newTab.Content = frame; frame.Navigate(typeof(BrowserTab), url); //new MessageDialog(MyTabView.Height.ToString(), "消息提示").ShowAsync(); return(newTab); }
private async void SymbolsTab_AddTabButtonClick(WinUI.TabView sender, object args) { var textBox = new TextBox { AcceptsReturn = false, Text = "GOOGL" }; var dialog = new ContentDialog { Content = textBox, Title = "Add a new stock symbol", IsSecondaryButtonEnabled = true, PrimaryButtonText = "Let's see", SecondaryButtonText = "No thanks" }; if (await dialog.ShowAsync() == ContentDialogResult.Primary) { var newTab = new WinUI.TabViewItem(); newTab.Header = textBox.Text; sender.TabItems.Add(newTab); sender.SelectedIndex = sender.TabItems.Count - 1; } }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { currentSelectedTab = TabControl.SelectedItem as muxc.TabViewItem; if (currentSelectedTab != null) { currentSelectedWebView = currentSelectedTab.Content as WebView; } if (currentSelectedWebView != null) { AppTitle.Text = "Pulse Ignite Browser | " + currentSelectedWebView.DocumentTitle; } if (!statusText.Text.Contains("BlankPage") && currentSelectedWebView != null) { statusText.Text = currentSelectedWebView.Source.AbsoluteUri; } else { statusText.Text = "Blank Page"; } }
private void TabControl_AddTabButtonClick(muxc.TabView sender, object args) { var newTab = new muxc.TabViewItem(); newTab.IconSource = new muxc.SymbolIconSource() { Symbol = Symbol.Document }; newTab.Header = "Blank Page"; WebView webView = new WebView(); string path = $"ms-appx-web:///Assets/BlankPage.html"; newTab.Content = webView; webView.Navigate(new Uri(path)); sender.TabItems.Add(newTab); sender.SelectedItem = newTab; }
internal TabViewTabDragCompletedEventArgs(DragItemsCompletedEventArgs args, object item, TabViewItem tab) { _args = args; Item = item; Tab = tab; }
internal TabViewTabDragCompletedEventArgs(DataPackageOperation dropResult, object item, TabViewItem tab) { DropResult = dropResult; Item = item; Tab = tab; }
internal TabViewTabDragStartingEventArgs(DragItemsStartingEventArgs args, object item, TabViewItem tab) { _args = args; Item = item; Tab = tab; }
internal TabViewTabDragStartingEventArgs(DataPackage data, object item, TabViewItem tab) { Data = data; Item = item; Tab = tab; }
protected override void OnNavigatedTo(NavigationEventArgs e) { var ctvi = e.Parameter as Microsoft.UI.Xaml.Controls.TabViewItem; currentTabVI = ctvi; }