穷人一个,分少。
求大神详解
------解决思路----------------------
if (this.radiobutton3.IsChecked==true){
‘选中
}
else{
‘未选中
}
------解决思路----------------------
前台xaml:
<Grid>
<StackPanel>
<RadioButton x:Name="rbA" Content="选项A" GroupName="group1"></RadioButton>
<RadioButton x:Name="rbB" Content="选项B" GroupName="group1"></RadioButton>
</StackPanel>
</Grid>
后台:
放在构造函数中。
rbA.Checked += new RoutedEventHandler(radio_Checked);
rbB.Checked += new RoutedEventHandler(radio_Checked);
rbA.Unchecked += new RoutedEventHandler(radio_Unchecked);
rbB.Unchecked += new RoutedEventHandler(radio_Unchecked);
void radio_Unchecked(object sender, RoutedEventArgs e)
{
RadioButton btn = sender as RadioButton;
if (btn == null)
return;
if (btn.Name == "rbA")
{
}
if (btn.Name == "rbB")
{
}
}
void radio_Checked(object sender, RoutedEventArgs e)
{
// 同UnChecked判断。
}