有一个需求,我们有很多条目,需要选择一个条目作为当前条目,这就需要用到单选,就需要在DataGrid中使用RadioButton, 我的数据中有一个字段为is_current, 为bool值,在RadioButton中,有一个IsChecked绑定是否选择,所以可以直接绑定is_current
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<RadioButton Tag="{Binding id}" IsChecked="{Binding is_current}" Checked="RadioButtonChecked" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>