Reputation: 583
How the hell do you programmatically close a TabItem in a Windows 8 WPF Desktop TabControl?
There are no options in Intellisense, and the only things that appear in search results are custom implementations of either the TabControl or the TabItem.
Why can't we just do something like tabControl.SelectedItem.Close();
?
Upvotes: 0
Views: 2347
Reputation: 1437
I think that closing is the same as removing TabItem from TabControl
Edit: For Ex:
tabControl1.Items.RemoveAt(tabControl1.SelectedIndex);
Upvotes: 5
Reputation: 32449
You cannot close it. TabItem
is not closeable. You can just hide it:
tabControl.SelectedItem.Visibility = System.Windows.Visibility.Collapsed
Upvotes: 1