I've been trying to capture the values that a user enters into a datagrid by using
<b:Interaction.Triggers>
<b:EventTrigger EventName="RowEditEnding">
<b:InvokeCommandAction Command="{Binding ReleaseRowEditEndingCommand}" CommandParameter="{Binding SelectedRelease}"/>
</b:EventTrigger>
But this doesn't work and I now understand this afte reading this article on StackOverflow. The solutions presented all seem to be based on directly calling a method signature that matches the event being raised, in this case
private void OnRowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
Has anyone accomplished getting the values post-rowedit in an MVVM situation? All the solutions seem to tightly bind the event to the XAML and I'd like to avoid that, if possible.
The solution was actually easier than I thought. I changed the XAML and I can now get the values in the RowEditEnding event on the View Model. Here's the before on 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With