Cannot find source for binding

As Zarat mentioned the default style for TabItem in Windows 8 has triggers that fire after the remove and then look for the now missing TabControl. I consider that a bug because adding and removing TabItems is a really common scenario isn’t it?

I found as a workaround, that it is possible to remove the template of the TabItem:

foreach (var item in TabControl.Items)
{
    var tabitem = item as TabItem;
    // if this is the item to remove
    tabitem.Template = null;
    TabControl.Items.Remove(item);
}

That looks ok in my scenario, because I will not use the TabItem any more.

I also tried clearing the triggers collection of the template or clearing the conditons collection of its triggers, but it is not allowed to do that (errors).
Also there does not seem to be a way tot disable the triggers.

Leave a Comment