Immediate action after checking checkbox in GridView

741 views Asked by At

I'm developing a MVVM-based system with DevExpress WPF controls and Simple MVVM Toolkit. There is a case where I am displaying a GridControl where the viewmodel of each row in the grid has got a boolean property (among others). This property is displayed in the GridControl as a checkbox.

I want to update another view in the window right after the user selects or deselects that checkbox, but that does not seem to work. I have put some code in the property setter that would update the view but this is only executed after the user clicks outside of the GridControl's row. So it takes 2 steps to execute the setter:

  1. Select or deselect the checkbox
  2. Click to select another row in the gridcontrol

Can I have the setter executed right after step 1?

I can imagine it has got something to do with the Simple MVVM Tooklkit behavior that when a viewmodel is in its "editing" state, it is cloned and only when the "editing" state is ended, the properties are set to the new values.

I'd appreciate any insights on this.

Best regards, ~Rob

1

There are 1 answers

1
gomi42 On

This has been discussed here several times. Just use a DataGridTemplateColumn like this:

    <DataGridTemplateColumn Width="Auto" Header="Selected">
      <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <Grid>
            <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                            HorizontalAlignment="Center" 
                            VerticalAlignment="Center"/>
          </Grid>
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>