'DataGrid Controls WPF
I want to use radio button in datagrid (wpf) in a way that, instead of showing data in text format in datagrid column, I want the data to be shown in radio button. But can't find the way to that. As it gives error in FindControl Function.
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
<RadioButton Name="rb_Present" GroupName="CMGrp" Content="Present" IsChecked="{Binding Path=is_selected, Mode=TwoWay}"></RadioButton>
<RadioButton Name="rb_Late" GroupName="CMGrp" Content="Late" IsChecked="{Binding Path=is_selected, Mode=TwoWay}"></RadioButton>
<RadioButton Name="rb_Absent" GroupName="CMGrp" Content="Absent" IsChecked="{Binding Path=is_selected, Mode=TwoWay}"></RadioButton>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
foreach (GridView row in dtAttendance.Items)
{
RadioButton rb = (RadioButton)row.FindName("RadioButton1");
}
dtAttendance.ItemsSource = dt.DefaultView;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
