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

有帮助吗?

解决方案

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)); 

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top