0

I have a problem adding a checkbox-column to a WPF-datagrid.

  1. I create a datatable with 8 columns and fill it using sql.
  2. 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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.