Hi,
I am binding a list to a xamdatagrid through mvvm. This list is ordered through the xaml properties of the grid so the ordering in the grid shown is not equal to the ordering of my list used in the viewModel. The results list is filled from a call to a service. Now on certain actions a row is removed from the list and we call the service again to get an refresh list. The problem is we would like to select the next row in the grid (if it is still in the list after the refresh) but we have no way of finding out what the next element in the datagrid is as our list in the viewmodel doesn't have the same order. Is there I way I can get the data of the next item in the datagrid?
I have made a small simplified example that I attached to this post.
Thanks!
Hello ,
Thank you for your post.
I have been looking into the functionality you are looking for and the sample application you have attached. If you would like to follow the MVVM pattern you should not access the XamDataGrid(your view) through the ViewModel. What I can suggest is to create a behavior for XamDataGrid. In this behavior you can create command property of type ICommand and bind it for your RemoveCommand, so in the behavior you can listen for DataSourceChanged event and implement the logic you wish in it’s event handler. You can read more details about behaviors from the following link:
https://msdn.microsoft.com/en-us/library/ff725476%28v=expression.40%29.aspx?f=255&MSPPError=-2147217396
I have modified your sample application in order to show you a guideline for implementing the functionality that you are looking for.
Please let me know if you require any further assistance regarding this matter.
Thank you for your response. Unfortunately DataSourceChanged has only been added in version 15.2 and we are still using version 13.1 on my project and an upgrade is not an option at the moment. Is there another solution/work around to this problem?
Best regards.
Hello,
It seems that currently the best approach I can suggest in order to achieve the functionality you are looking for is to use the DataSourceChagned event of XamDataGrid.
Please let us know if you have any further questions regarding this matter.
Sincerely, ZhivkoEntry Level Software Developer