Skip to main content

Microsoft Silverlight

Answered Question does datagrid have a SelectionChanging event?RSS Feed

(0)

EverettLiu
EverettLiu

Member

Member

79 points

60 Posts

does datagrid have a SelectionChanging event?

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
Isaak

Member

Member

530 points

94 Posts

Re: does datagrid have a SelectionChanging event?

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

EverettLiu
EverettLiu

Member

Member

79 points

60 Posts

Re: Re: does datagrid have a SelectionChanging event?

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
yifung

Contributor

Contributor

3315 points

541 Posts

Microsoft

Re: Re: does datagrid have a SelectionChanging event?

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

Yifung Lin [MSFT]

EverettLiu
EverettLiu

Member

Member

79 points

60 Posts

Re: Re: does datagrid have a SelectionChanging event?

 Hi yifung, my datagrid itemsource is a ObservableCollection, how convert it to CollectionView type?

yifung
yifung

Contributor

Contributor

3315 points

541 Posts

Microsoft

Re: Re: does datagrid have a SelectionChanging event?

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.

Yifung Lin [MSFT]

EverettLiu
EverettLiu

Member

Member

79 points

60 Posts

Re: Re: Re: does datagrid have a SelectionChanging event?

 thanks yifung,

Can you tell me the time period when silverlight will be released
in this summer or any roadmap ?

yifung
yifung

Contributor

Contributor

3315 points

541 Posts

Microsoft
Answered Question

Re: Re: Re: does datagrid have a SelectionChanging event?

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.

Yifung Lin [MSFT]
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities