private void bShowTable_Click(object sender, RoutedEventArgs e) { TabItem newTi = new TabItem(); a7DbSearchEngine.a7TableSelection tableSel = (lbTables.SelectedItem as a7DbSearchEngine.a7TableSelection); if (tableSel != null) { string tableName = (lbTables.SelectedItem as a7DbSearchEngine.a7TableSelection).TableName; newTi.Header = tableName; a7TableExplorer tEx = DBSearch.ExploreTable(tableName); TableExplorer tExControl = new TableExplorer( () => { tcTableExplorer.Items.Remove(newTi); DBSearch.TableExplorers.Remove(tableName); } ); tExControl.DataContext = tEx; newTi.Content = tExControl; tcTableExplorer.Items.Add(newTi); tiTableExplorer.IsSelected = true; } }