private void tabControl_TabItemAdded(object sender, TabItemEventArgs e) { // wrap the header in a textblock, this gives us the character ellipsis (...) when trimmed TextBlock tb = new TextBlock(); switch(SectionSelected) { case Wpf.Controls.TabControl.Section.WIP: tb.Text = "Wip"; this.Title = "Work in Progress"; break; case Wpf.Controls.TabControl.Section.INV: tb.Text = "Inv"; this.Title = "Inventory"; break; case Wpf.Controls.TabControl.Section.INOUT: tb.Text = "InOut"; this.Title = "In-/OutBound"; break; case Wpf.Controls.TabControl.Section.OUTBOUND: tb.Text = "Outbound"; this.Title = "Outbound"; break; case Wpf.Controls.TabControl.Section.INBOUND: tb.Text = "Inbound"; this.Title = "Inbound"; break; case Wpf.Controls.TabControl.Section.RETURN: tb.Text = "Return"; this.Title = "Return"; break; case Wpf.Controls.TabControl.Section.DOCK: tb.Text = "Dock"; this.Title = "Dock"; break; case Wpf.Controls.TabControl.Section.REPORT: tb.Text = "Reporting"; this.Title = "Reporting"; break; case Wpf.Controls.TabControl.Section.TASKS: tb.Text = "Tasks"; this.Title = "Tasks"; break; case Wpf.Controls.TabControl.Section.BILL: tb.Text = "Billing"; this.Title = "Billing"; break; case Wpf.Controls.TabControl.Section.ADMIN: tb.Text = "Admin"; this.Title = "Admin"; break; default: tb.Text = "WMS"; this.Title = "Warehouse Management System"; break; } tb.TextTrimming = TextTrimming.CharacterEllipsis; tb.TextWrapping = TextWrapping.NoWrap; e.TabItem.Header = this.Title; }
void tabControl_TabItemAdded(object sender, TabItemEventArgs e) { // Add an Icon to the tabItem BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Test;component/Images/ie.ico")); Image img = new Image(); img.Source = image; img.Width = 16; img.Height = 16; img.Margin = new Thickness(2, 0, 2, 0); e.TabItem.Icon = img; // wrap the header in a textblock, this gives us the character ellipsis (...) when trimmed TextBlock tb = new TextBlock(); tb.Text = "New Tab " + count++; tb.TextTrimming = TextTrimming.CharacterEllipsis; tb.TextWrapping = TextWrapping.NoWrap; e.TabItem.Header = tb; // add a WebControl to the TAbItem WindowsFormsHost host = new WindowsFormsHost(); host.Margin = new Thickness(2); System.Windows.Forms.WebBrowser browser = new System.Windows.Forms.WebBrowser(); browser.DocumentTitleChanged += Browser_DocumentTitleChanged; browser.Navigated += Browser_Navigated; host.Child = browser; e.TabItem.Content = host; }