views:

34

answers:

1

I need to change the order of the TabItem.

I've tried with Remove / Insert and it doesn't works.

void UserControl_Loaded(object sender, RoutedEventArgs e) {
  if(condition) {
    TabControl.Items.Remove(TabItem);
      TabControl.Items.Insert(0, TabItem);
    }
}

InvalidOperationException: Element already has a logical parent. It must be detached from the old parent before it is attached to a new one.

How to solve this?