private void Dell_Sector(object sender, RoutedEventArgs e) { object selectedItem = TreeQuestion.SelectedItem; if (selectedItem != null) { TreeQuestion.Items.Remove(selectedItem); string indexSector = (string)((TreeViewItem)selectedItem).Header; DataTicket.RemoveSector(Int32.Parse(indexSector)); } }
private void Del_Question(object sender, RoutedEventArgs e) { var SelectedTreeViewItem = (TreeViewItem)TreeQuestion.SelectedItem; if (SelectedTreeViewItem == null) { return; } var parent = (TreeViewItem)SelectedTreeViewItem.Parent; string indexSector = (string)parent.Header; string indexQuestion = (string)SelectedTreeViewItem.Header; DataTicket.RemoveQuestion(Int32.Parse(indexSector), Int32.Parse(indexQuestion)); parent.Items.Remove((object)SelectedTreeViewItem); }