How to add Close Button in tab of Dynamic WPF Tab control
c#, tabcontrol, wpf
Solution
TabControl does not provide the ability to close TabItems.
You could add a 'x' button and set the visibility to Collapsed / Hidden as a hack.
OR You could look at XamTabControl by Infragistics or any other vendor product which does support closing of Tabs.
Problem
I have a WPF Tab Control.. i am adding tabs in that TabControl dynamically Now i want to give a Close Button in every Tab of Tab Control.. So please tell me hopw to add Close button in that Tab Control.. Code for adding tab ``` private void AddTab(ITabbedMDI mdiChild) { if (_mdiChildren.ContainsKey(mdiChild.UniqueTabName)) { //user control is already opened in tab. //So set focus to the tab item where the control hosted foreach (object item in tcMdi.Items) { TabItem ti = (TabItem)item; if (ti.Name == mdiChild.UniqueTabName) { ucChildLoc = (UserControl)mdiChild; ti.Focus(); //tcMdi.Width = this.ucChildLoc.Width; //tcMdi.Height = this.ucChildLoc.Height; break; } } } } ``` Code for Closing tab ``` private void CloseTab(ITabbedMDI tab, EventArgs e) { TabItem ti = null; foreach(TabItem item in tcMdi.Items) { if (tab.UniqueTabName == ((ITabbedMDI)item.Content).UniqueTabName) { ti = item; break; } } if (ti != null) { _mdiChildren.Remove(((ITabbedMDI)ti.Content).UniqueTabName); tcMdi.Items.Remove(ti); } } ``` I am using TabControl of this article http://www.codeproject.com/Articles/32362/Tabbed-MDI-in-WPF Thanks in Advance..