Hello, I am a teacher and I am creating my first Xamarin app. I am using Prism for my MVVM framework and one of your grids. I have a screen listing all the sections I teach (bound to an observable collection in my view model). When the I select a section and click on a button I want to navigate to a page with a list of students in that section.
The trouble is that I don’t know what row was selected when I am in my view model. I don’t want to go into the code behind as shown in the documentation. I thought there would be a property in the grid (selected items?) that I could bind to my view model so that when I click the button I would know what section had been selected.
What would be the best way to achieve this with the Infragistics grid?
Hello Jim,
I have been investigating into the behavior you are trying to achieve in this case, and currently the selected item of the XamDataGrid in Infragistics for Xamarin.Forms is not bindable, as the SelectedItems and SelectedKeys properties are not bindable properties.
While these properties are not bindable at the moment, this is not to say that the selected items cannot be kept track of in an MVVM way. I would recommend continuing with what is listed in our documentation, but handle the SelectedItemsChanged event in a Behavior<XamDataGrid> that you can then add to the XamDataGrid.Behaviors collection. This will allow you to keep track of the selected items in an MVVM way. There is a good example of usage of Xamarin.Forms Behaviors here.
Please let me know if you have any other questions or concerns on this matter.