I have a XamDataGrid which is bound to an ObservableCollection of Business Objects. When I select a single item I am able to get the ActiveDataItem cast to the Business Object's type and conveniently able to use the properties on the object to get the values of the selected item. I am trying to achieve this when I select multiple records on the grid. I'm not able to cast the item objects in SelectedItems property of the grid and hence unable to get a collection of selected business object type items. How could I achieve this? Please help.
Thanks,
Shravan
Thought I'd answer my own question after getting the answer elsewhere in case someone comes in here looking for help. My issue was that I did not set the CellClickAction to SelectRecord in FieldSettings. Once I set it, then it worked.
Anybody?
Thanks.
Mike
Vlad,
I'm trying this and can't get it to work. I can see that I have SelectedItems and can even get a count of them, but when I use the pattern above, I get a count of 0. Is there something I might be missing?
Shravan,
You can use the SelectedItems.Records collection to iterate through all of the selected records and obtain the dataobject using DataItem property e.g.
SelectedRecordCollection src = xamDataGrid1.SelectedItems.Records;
foreach (DataRecord record in src)
{
MyClass obj=record.DataItem as MyClass;
}
Let me know if you have any questions with this matter.