My datagrid is bound to an observable collection, The datagrid has two columns - one for radio buttons, another to display names. At the moment, I am able to make multiple selections on the datagrid, But my requirement is to select only one radio button at a time such that the selected radio button should notify the viewmodel about the selected user name. How can i achieve it ?
Here's what I tried:
<DataGrid Width="{Binding ActualWidth, ElementName=panel}"
ItemsSource="{Binding obvUsers}"
Height="390" >
<DataGrid.Columns>
<DataGridTemplateColumn Header="" Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<RadioButton IsChecked="{Binding IsUserSelected}"
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Name">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding UserName}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>