Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1415
Use Command on edit in XamDataGrid
posted

How can I call a MVVM command after an editable cell has been changed?

I would like to update a label outside of the grid with the sum of one of the grid's columns

  • 34830
    Offline posted

    Hello PMac,

    In order to call an MVVM command after an editable cell has been changed in the XamDataGrid, I would recommend that you include the System.Windows.Interactivity assembly and utilize an EventTrigger with an InvokeCommandAction. You can read about these classes here: https://github.com/Microsoft/XamlBehaviors/wiki/InvokeCommandAction.

    In the EventTrigger, you can target the EditModeEnded event of the grid by setting the EventName property of the EventTrigger to "EditModeEnded", as this will fire whenever a cell in the grid leaves edit mode. Then, you simply need to bind the Command property of your underlying ViewModel to the resultant InvokeCommandAction.

    I have attached a sample project to demonstrate the above. I hope this helps.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XDGEditEventCommandDemo.zip