private void DeleteClick(object sender, RoutedEventArgs e) { if (MessageBox.Show($"Are you sure you want to delete \"{EntityName}?\" (This includes any relationships it has with other entities)", "Delete Entity", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var entity = (from c in EntityType.Handle.Root.Elements() where c.Element("name").Value.Equals(EntityName) select c).First(); entity.Remove(); EntityType.Save(); if (EntityType.Name.Equals(XMLParser.CharacterXDocument.Name)) { //Remove from parents, children, ismarried, wasmarried, participants XMLParser.RemoveCharacterFromRelationships(EntityName); } else if (EntityType.Name.Equals(XMLParser.LocationXDocument.Name)) { //remove from event locations XMLParser.RemoveLocationFromEvents(EntityName); } } }