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
130
How to find the row index of a modified cell in the XamGrid ?
posted

We have an MVVM application which uses a XamGrid (v12.1) bound to a BindingList. When a cell in the XamGrid is modified, the View needs to notify the row index of the modified cell to the View Model. For this, I used the CellExitedEditMode event to get the row index as follows:

void OnCellExitedEditMode(object sender, CellExitedEditingEventArgs e)

{     int rowIndex = e.Cell.Row.Index;  }

The above code stops working after the user performs a sort operation. After the XamGrid is sorted, the row index obtained using the method above is not the same as the row index from the BindingList. 

How can I get the correct row index of the cell that was changed by the user ?

Parents
No Data
Reply
  • 138253
    Verified Answer
    Offline posted

    Hello Koshy,

    Thank you for your post. I have been looking into it and I can suggest you use the following code in order to get the index of the currently edited item directly from the BindingList, where the indexes doesn’t change:

    int index = (sender as XamGrid).ItemsSource.OfType<object>().ToList().IndexOf(e.Cell.Row.Data as ChartData);
    
     

    where "ChartData" is your data type. Please let me know if this helps you or you need further assistance on this matter.

    Looking forward for your reply.

Children