Closeable tab item

This section demonstrates the use of the closeable tab item:

MainWindow.xaml

A tab control is placed in a window.

<Window Title="Example Project" x:Class="ExampleProject.MainWindow" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
	<TabControl x:Name="exampleTabControl"/>
</Window>

MainWindow.xaml.cs

A closeable tab item is instantiated and given a title before being put into the tab control:

namespace ExampleProject
{
	using System.Windows;
	using Emi.UserControls;

	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			this.InitializeComponent();

			// The constructor takes no arguments.
			CloseableTabItem exampleCloseableTabItem = new CloseableTabItem();

			// The tab item is given a title.
			exampleCloseableTabItem.Title = "Example Title";

			// The tab item is added to a tab control.
			this.exampleTabControl.Items.Add(exampleCloseableTabItem);
		}
	}
}

Closeability

Closeable tab items are closeable by default but the closeability can be changed:

			// The tab item is made uncloseable.
			exampleCloseableTabItem.IsCloseable = false;

Gallery

A demonstration of a tab control with closeable tab items.