I have a button in my user control which should be used to remove the user control from its parent container. This is the way I have coded it today.
private void RemoveRoleButton_Click(object sender, RoutedEventArgs e)
{
if (ConfirmRoleRemoval())
{
Panel parentPanel = (Panel)this.Parent;
parentPanel.Children.Remove(this);
}
}
private bool ConfirmRoleRemoval()
{
return MessageBox.Show("Are you sure [...]
}
Is it normal to do it this way in WPF?