Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit does datagrid have a SelectionChanging event?
7 replies. Latest Post by yifung on April 27, 2009.
(0)
EverettLiu
Member
79 points
60 Posts
04-24-2009 2:10 AM |
When select an other row in datagrid, I want to handle the selectionchanging event that I can cancel selection change,
just like keydown event
any suggestions are welcome .
Isaak
530 points
94 Posts
04-24-2009 2:59 AM |
If I understand well, perhaps something like
myDataGrid.SelectedItems=null
after selection changed could work if you just want to unselect the row.
Please mark as answered if it helped solving you problem
04-24-2009 5:51 AM |
Sorry, Maybe I described is not clear enough
first select one row in datagrid,
when selecting another row, I want to cancel the selection, and still select the previous selected row
yifung
Contributor
3315 points
541 Posts
04-24-2009 6:55 PM |
Unfortunately, this event does not exist today. In SL 3, you will be able to listen to the CurrentChanging event off of the CollectionView and cancel that. This will solve the problem for you in single selection but not for all multiple selection scenarios without doing some more work
04-24-2009 9:50 PM |
Hi yifung, my datagrid itemsource is a ObservableCollection, how convert it to CollectionView type?
04-27-2009 1:54 PM |
Unfortunately, you cannot convert from an ObservableCollection to a CollectionView. In Silverlight 3, there will be a public CollectionView available so you would create a CollectionView that wraps your ObservableCollection. Then, you would set the ItemsSource of the DataGrid to that CollectionView.
04-27-2009 8:47 PM |
thanks yifung,
04-27-2009 8:57 PM |
The Silverlight 3 Beta released in March. You could give that a try. As for the final Silverlight 3 release, I'm afraid I can't give any details. A lot of times for these things, the public rumors aren't too far off though.