private void DeleteButton_Click(object sender, RoutedEventArgs e) { ListViewView listView = FocusedTabControl.SelectedContent as ListViewView; TreeListView treeListView = FocusedTabControl.SelectedContent as TreeListView; if (listView != null) { listView.Delete(); } else { treeListView.Delete(); treeListView.RefreshSelectedItem(); } RefreshTabs(); }