I\'m writing a custom ItemsControl (a tabbed document container), where each item (tab) can remove itself from the UI when the user closes it. However, I can\'t
The ItemCollection returned by ItemsControl.Items won't allow you to call Remove directly, but it implements IEditableCollectionView and does allow you to call the Remove method in that interface.
This will only work if the collection view bound to ItemsSource implements IEditableCollectionView itself. The default collection view will for most mutable collections, although not for objects that implement ICollection but not IList.
IEditableCollectionView items = tabControl.Items; //Cast to interface
if (items.CanRemove)
{
items.Remove(tabControl.SelectedItem);
}