4

I´m initializing the DataGrid in XAML but the Columns are generated in the code because columns are varying based on the input data. However when DataGridCheckBoxColumn is generated I cannot check/uncheck the single checkbox in any row of this column. Some of them are checked/unchecked based on the value of bool "checkFlag"

DataGridCheckBoxColumn checkColumn = new DataGridCheckBoxColumn();
checkColumn.Header = "Save";
checkColumn.Binding = new Binding("checkFlag");
checkColumn.MinWidth = 50;
vysledkyDataGrid.Columns.Add(checkColumn);

<DataGrid AutoGenerateColumns="false" 
          Margin="20,247,25,94" 
          Name="vysledkyDataGrid"
          IsEnabled="True" 
          CanUserReorderColumns="False" 
          CanUserResizeColumns="True" 
          CanUserSortColumns="False" 
          HorizontalGridLinesBrush="DarkGray"              
          VerticalGridLinesBrush="DarkGray" 
          ClipboardCopyMode="None" 
          IsReadOnly="True">
        <DataGrid.ColumnHeaderStyle>
            <Style TargetType="{x:Type DataGridColumnHeader}">
                <Setter Property="HorizontalAlignment" Value="Stretch" />
                <Setter Property="HorizontalContentAlignment" Value="Center" />
            </Style>
        </DataGrid.ColumnHeaderStyle>
        <DataGrid.CellStyle>
            <Style TargetType="DataGridCell">
                <Setter Property="Block.TextAlignment" Value="Right"/>
            </Style>
        </DataGrid.CellStyle>
    </DataGrid>
1
  • Can you share your xaml? Commented Jul 1, 2014 at 12:19

1 Answer 1

10

Your DataGrid has a property ReadOnly = true. You have to set it to ReadOnly = false to make it editable,so you would be able to check/uncheck the CheckBox. Regards

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

1 Comment

That was so easy ... :-) Many Thanks

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.