lukang423 2015-09-15 02:44 采纳率: 20%
浏览 2189

wpf的一条关于RadioButton的问题


人员1
人员2
人员3

string s1;
private void Group_Checked(object sender,RoutedEventArgs e)
{
RadioButton r=e.Source as RadioButton;
if(r.IsChecked==true)
s1.r.Content.ToString();
}

对于这段代码,我有好几个问题想问:
1.RadioButton.Checked这里,没有指定是哪个RadioButton,执行起来怎么知道是哪个?
2.RadioButton r=e.Source as RadioButton这是什么意思?执行这句后,r表示哪个RadioButton?

  • 写回答

1条回答 默认 最新

  • 关注

    是额。2: Source 就是 表示该事件的触发源,所以会是object 类型的。 as 就是转换成对应的对象。你可以在xaml中 设置name,在后台进行区分。

    评论

报告相同问题?