Skip to content

Closing a MetroTabItem added from a child. #1278

@andySF

Description

@andySF

I have a MetroAnimatedSingleRowTabControl in my Window and from a UserControl I add programmaticaly a MetroTabItem to it like so:

object foundTabControl = parentWindow.FindName("metroAnimatedSingleRowTabControl");
MetroAnimatedSingleRowTabControl metroAnimatedSingleRowTabControl = (MetroAnimatedSingleRowTabControl)foundTabControl;
MetroTabItem metroTabItem = new MetroTabItem();
metroTabItem.Content = newSomeUserControl;
metroTabItem.CloseButtonEnabled = true;
metroAnimatedSingleRowTabControl.Items.Insert(index,metroTabItem);
metroAnimatedSingleRowTabControl.SelectedIndex = index;
metroAnimatedSingleRowTabControl.Items.MoveCurrentToLast();

When I close this tab I get a InvalidOperationException saying that Operation is not valid due to the current state of the object.

The other tabs added from XAML don't have a close button but if I set the CloseButtonEnabled="True" it's working. The problem is just with the TabItems added from the child.

Is this a limitation or I just lack the knowledge to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions