Tony Vitabile
Tony Vitabile

Reputation: 8614

How to detect a click on the selected row of a RadGridView control

My WPF application uses the Telerik RadGridView control on a few of its screens. I have a requirement that says that whenever the user clicks on a row in the RadGridView, I'm supposed to switch to another screen and display detail information about that row. I hooked up a handler to the SelectionChanged event and this works, except that nothing happens if the user clicks on the selected row a second time. This makes sense, as the selected row isn't being changed.

How can I detect a second click on the same row and have the second screen displayed?

Tony

Upvotes: 1

Views: 4702

Answers (2)

jimmyjambles
jimmyjambles

Reputation: 1670

You could just attach a handler to the MouseUp event on the GridView. Check if there are any selected cells and respond from there. This will fire even if there is already a selection.

The MouseDown event will fire on the mouse click, but before the gridview updates the selction, mouse up should fire when the selection has already been adjusted

You can also attach a handler to each individual cell in code-behind as follows

(this.GridView as RadGridView).AddHandler(  
     GridViewCell.MouseUpEvent,  
     new EventHandler<Telerik.Windows.RadRoutedEventArgs>(this.OnMouseUp)); 

Upvotes: 2

David Bekham
David Bekham

Reputation: 2175

I think you may try to achieve this through the MouseLeftButtonDown event or PreviewMouseLeftButtonDown event.

Upvotes: 0

Related Questions