WPF Datagrid RowEditEnding on MVVM

I am trying to capture the values ​​that the user enters into a datagrid using

<b:Interaction.Triggers> <b:EventTrigger EventName="RowEditEnding"> <b:InvokeCommandAction Command="{Binding ReleaseRowEditEndingCommand}" CommandParameter="{Binding SelectedRelease}"/> </b:EventTrigger> 

But this will not work, and now I understand that it read the this article on StackOverflow. All the solutions presented are apparently based on a direct call to the signature of the method that corresponds to the raised event, in this case

 private void OnRowEditEnding(object sender, DataGridRowEditEndingEventArgs e) 

Has anyone done getting post-rowedit values ​​in an MVVM situation? All solutions seem to bind the event strongly to XAML, and I would like to avoid this if possible.

+4
source share
2 answers

The solution was easier than I thought. I changed the XAML, and now I can get the values ​​in the RowEditEnding event on the view model. Here before the data columns on the datagrid:

  <DataGrid.Columns> <DataGridCheckBoxColumn Header="Is Paid" Binding="{Binding IsPaid, Mode=TwoWay}" /> <DataGridTextColumn Header="Amount" Binding="{Binding Amount, Mode=TwoWay}" /> </DataGrid.Columns> 

After

  <DataGrid.Columns> <DataGridCheckBoxColumn Header="Is Paid" Binding="{Binding IsPaid, UpdateSourceTrigger=PropertyChanged}" /> <DataGridTextColumn Header="Amount" Binding="{Binding Amount, UpdateSourceTrigger=PropertyChanged}" /> </DataGrid.Columns> 
+1
source

You can try to wrap your data in a ListCollectionView and bind the DataGrid to a ListCollectionView. Then in your ViewModel, hook into the ListCollectionView.CurrentChanging event to process your changes before moving on to a new line.

0
source

All Articles