0
你好,我有两个单选按钮。一男一女。问题是,当他们中的一个被选中(例如男性),并且用户试图改变到另一个(女性)时,我向用户显示一条警告消息。如果他按确定radio-button从女性变为男性,一切都好。但是当他按下取消按钮时,男女之间也会发生变化。我如何防止这种情况?有什么办法来禁用radiobutton_checked监听器,并启用每当我想要?
用于男性和女性听众的代码是下一个:
单选按钮改变警告信息
private void NewTrdButtonMale_Checked(object sender, RoutedEventArgs e)
{
//if there are participants for deletion i display a warning message that says that if you change from female to male the deletion will be done
if (newAreParticipantsForDeletion())
{
switch (warningMessage())
{
case "OK":
//nothing useful for you here
break;
case "Cancel":
break;
}
}
else
{
//nothing interesting here
}
}
private void NewTrdButtonFemale_Checked(object sender, RoutedEventArgs e)
{
//it is the same code as the above but it is for female
}
上述方法是用于单选按钮的监听器。那我想做的是,如果用户按取消不做任何更改。但这是困难的部分,因为我已经在男性托管的听众的内部,所以变更已经完成。
请问您可以发布您的代码吗? –
WPF,Winforms还是Win8? – OmegaMan
对不起,我发布了它,但我不确定它是非常有用的。这是wpf。 – userX