- Click once on a row and the map is zoomed to that single point (i have this working, using the SelectionChanged event)
- Click on the same row again and reset back to the full map.
The second bullet is what I am having a hard time with. I can't seem to just capture single clicks. Any ideas?
10 Answers, 1 is accepted
The approach would be to add a handler directly to RadGridViewRow. Please check the following code snippet for a reference:
this.AddHandler(GridViewRow.MouseLeftButtonDownEvent,
new MouseButtonEventHandler(OnMouseLeftDown), true);
public void OnMouseLeftDown(object sender, MouseButtonEventArgs e)
{ }
I hope this helps.
Yoan
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I need to be able to manage single and double clicks on a row. Currently I am using the MouseDown for a single click (works fine) and the MouseDoubleClick for double clicks. Problem is the single event always overrides the double click. I can I manage the two of them?
In this case, I can suggest you to handle the PreviewMouseDown event in combination with a Timer. I have attached a sample project which shows you the approach. Please take a look at it and let me know if you need any further assistance.
Regards,
Yoan
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Hi Micheal,
With the above event handling. Single mouse click is also firing on the empty area of the RADGRIDVIEW. It should be fire on the data grid rows.
Thanks,
Parmod
Hi Parmod,
Indeed, you are absolutely right. You can register a class handler like so:
EventManager.RegisterClassHandler(typeof(GridViewRow), GridViewRow.MouseLeftButtonDownEvent, new RoutedEventHandler(OnRowMouseDown),true);
and the handler will be invoked only when clicking on the GridViewRow element.
Regards,
Yoan
Progress Telerik
Hi Joan,
I would like to do different action if I just singleclick on the row or if I doubleclick on the row. I have tried to have an EventToCommandBehavior.EventBindings for each event (MouseDown and MouseDoubleClick). But then if I double click the row both events are fired which I don't want. Singleclick should move the selected item in the grid to another grid. And doubleclick should open an editor window for the item in the gridrow. The program will be used on a touchscreen so I want to avoid change to "right click" which was one idea.
Hi Christer,
Indeed, using the EventToCommand will not work for you in this scenario because you need to separate the events (The MouseDown event will be always firing). So, I can suggest sticking with the approach that I provided in this thread - using a Timer.
If you want to have your code-behind clean, the way to go is with an Attached behavior. Here you can find information about it. You will write the attached behavior only once. This attached behavior will attach to the event and you will be able to apply the functionality in it. Here is a very nice article about event handling with attached behaviors. You have the code in one place only. Then you can enable this attached behavior on a RadGridView. All you will need to do is something like this:
<RadGridView MyBehavior.IsEnabled="True"/> and then let the attached behavior kick in and do its job.
Regards,
Yoan
Progress Telerik