I want the checkbox column in my datagrid on / off for each row depending on the value in the collection. I have an ObservableCollection called AccountComponents, which is a collection of the AccountComponent class that has the boolean property Enabled. I tried binding the Enabled property to IsReadOnly and IsEnabled with no luck.
Here's the XAML where I tried DataGridCheckBoxColumn -
<DataGridCheckBoxColumn Binding="{Binding IsChecked}" IsReadOnly="{Binding AccountComponents/Enabled}"/>
Here's the XAML where I tried the DataGridTemplateColumn -
<DataGridTemplateColumn Header=""> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid> <CheckBox IsChecked="{Binding IsChecked,Mode=TwoWay}" IsEnabled="False"/> </Grid> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <Grid> <CheckBox IsChecked="{Binding IsChecked,Mode=TwoWay}" IsEnabled="{Binding Enabled}"/> </Grid> </DataTemplate> </DataGridTemplateColumn.CellEditingTemplate> </DataGridTemplateColumn>
Any help on this understanding is greatly appreciated.
source share