穷人一个,分少。
求高手详解
求高手详解
解决方案
10
10
前台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判断。 }