Reputation: 363
I have a problem adding a checkbox-column to a WPF-datagrid.
I bind the datatable to the WPF-datagrid using ItemsSource like:
XAML:
<DataGrid x:Name="dgOPListEntries" Grid.Row="1" Grid.ColumnSpan="2" Margin="5" ItemsSource="{Binding}" AutoGenerateColumns="True"></DataGrid>
CodeBehind:
dgOPListEntries.ItemsSource = dtOPListEntries.DefaultView;
So far, this works fine.
I now want to add a checkbox-column to the datagrid where I can select some rows. (The selected rows will then be updated on the sql server.)
Any help is appreciated.
Upvotes: 0
Views: 2852
Reputation: 437
If what you want is just to select some rows, you can use DataGrid.SelectionMode
and DataGrid.SelectionUnit
properties set to DataGridSelectionMode.Extended
and DataGridSelectionUnit.FullRow
, respectively.
In addition, DataGrid
creates checkbox column automatically for data of type bool
, if you can add a field to your items source.
Upvotes: 2