private void btnremove_Click(object sender, RoutedEventArgs e) { try { btnremove.IsEnabled = false; if (MessageBox.ShowBox("MessageID4", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes) { MachineRemoval objMachineRemoval = new MachineRemoval(objPositiondetails); objMachineRemoval.Owner = this; objMachineRemoval.ShowDialogEx(this); } } finally { btnremove.IsEnabled = true; } }