Hi,
how can i bind the selected row to my viewmodel? My problem is this: i bound the itemssource to the vm (works fine, the elements are shown) but in the code behind of the view the xamgrid has no rows. So i cannot set the selected row this way: myxamgrid.SelectionSettings.SelectedRows.Add(selectedRow);
What can i do?
You may want to try this:
private void GridReview_SelectedRowsCollectionChanged(object sender, SelectionCollectionChangedEventArgs<SelectedRowsCollection> e){ _viewModel.SelectedItemModel = e.NewSelectedItems.SingleOrDefault().Data as ItemModel;}
Is then event raised when you click on the RowSelector?
http://help.infragistics.com/NetAdvantage/Silverlight/2010.2/CLR4.0/?page=SL_xamGrid_Setting_Selection_Programmatically.html
You can add rows directly to the SelectedRows collection or you can set the IsSelected property of the row.
Now i know that we got another a bit wrong. I think i didn't explained my problem correctly.
I don't want to get the selected rows (that works fine), i want to set the selected rows programmatically.
If the event isn't raised then I doubt you are selecting rows. You would need to set the grid's SelectionSettings RowSelection property
http://help.infragistics.com/NetAdvantage/Silverlight/2010.2/CLR4.0/?page=InfragisticsSL4.Controls.Grids.XamGrid.v10.2~Infragistics.Controls.Grids.SelectionSettings_members.html
If you are clicking the row selector and not getting this event and you have RowSEelction set to something other then None, I would need to see a sample.
Thanks for your replies. Sorry for posting so lately.
No the event isn't raised. The suggestion made doesn't solve my problem.