HotFrost
HotFrost

Reputation: 1605

How to bind to DataGridCheckBoxColumn in MVVM

I have a view with this snippet:

<DataGrid AlternatingRowBackground="#FFF2F5F1"
          AutoGenerateColumns="False"
          Grid.Row="0"
          GridLinesVisibility="None"
          IsReadOnly="False"
          IsSynchronizedWithCurrentItem="True"
          ItemsSource="{Binding Path=ClassSessionAttendenceAll}"
          SelectedItem="{Binding Path=SelectedAttendence, Mode=TwoWay}"
          Margin="5,5,5,5"
          RowHeight="20"
          SelectionMode="Single"
          IsEnabled="{Binding AttendenceGridEnabled}">

          <DataGrid.Columns>
              <DataGridTextColumn Binding="{Binding Path=ClientName}"                                                             
                                  Header ="Client's name" Width="2*"  />
              <DataGridCheckBoxColumn Binding="{Binding Attended, Mode=TwoWay, UpdateSourceTrigger =PropertyChanged}"
                                      Header="Is Present?"   
                                      Width="*">

              </DataGridCheckBoxColumn>
          </DataGrid.Columns>
</DataGrid>

I am having problems to react on change to that DataGridCheckBoxColumn checkbox. The whole datagrid is bound to the List with DataGridTextColumn bound to property Attendance.ClientName and DataGridCheckBoxColumn bound to another property Attendance.Attended

So, how to get to that CheckBox changed in ModelView? I can get to Selected no problem.. but there is 'but' - the check event happens after select event and i don't get the selected state of that checkbox. I probably missing one step.. but need help to make it.. :).. Thanks!

Upvotes: 0

Views: 6463

Answers (1)

Related Questions