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
920
xamdatagrid select row shift
posted

When I select a row in xamdatagrid and click a button that handles some processing in the view model.

In the processing code, I delete the selected row and insert a row at the same position. The selected row in xamdatagrid is shifting one row down. Is this how xamdatagrid behaves or is it something else thats causing this shift? 

  • 2490
    Verified Answer
    Offline posted

    Hello Lala,

    When you click on a record in XamDataGrid to make a selection, you are effectively selecting the clicked record and also setting it to ActiveRecord. After that if you perform a deletion (e.g. with DataPresenterCommands.DeleteSelectedDataRecords) you are removing the selected record from the SeletedItems. The XamDataGrid keeps the ActiveRecord and in this case is set to the next one.

    If you want, you can set the ActiveRecord to null, when making the selection or just before deleting and this will remove the effect the row shifting down.
    To illustrate this I have created a small sample application, please find it as an attached file.

    XamDataGrid_AddRecord.zip