private void Storyboard_Loaded(object sender, RoutedEventArgs e) { this.Loaded -= Storyboard_Loaded; var frame = VisualTreeHelperEx.FindVisualParents <Frame>(this).FirstOrDefault(); if (frame != null) { mangedTabItem = frame.Parent as ClosableTabItem; mangedTabItem.Closed += MangedTabItem_Closed; } }