Hi telerik,
I wish to handle the event that the user clicks somewhere in the tree where there are no items.
I would have thought that the MouseDown fired but apparently it doesn't.
Do you have any advice on what to do?
Thanks,
Anders, Denmark
I wish to handle the event that the user clicks somewhere in the tree where there are no items.
I would have thought that the MouseDown fired but apparently it doesn't.
Do you have any advice on what to do?
Thanks,
Anders, Denmark
4 Answers, 1 is accepted
0
Hello Anders,
You can also find this realized in the attached solution. Please let us know if this is what you expect.
Best wishes,
Petar Mladenov
the Telerik team
The MouseLeftButton down event is handled by other RadTreeView's events. So you have to attach to it by the UIElement.AddHandler() method providing ability to use handled events:
this
.ExplorerTree.AddHandler(RadTreeView.MouseLeftButtonDownEvent,
new
MouseButtonEventHandler(ExplorerTree_MouseLeftButtonDown),
true
);
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Anders
Top achievements
Rank 1
answered on 13 Oct 2011, 10:08 AM
Hi Petar,
Yes, this way the event fires just fine!
However, I need to react only to clicks outside the tree items.
Can I translate the position of the click to an item somehow? I've looked at the methods on the treeview without finding any obvious candidates.
(Furthermore this event fires before the 'ordinary' treeview events making it hard to 'hack' it throgh e.g. registering time stamp om last click on items and then checking in the 'raw' click event).
Thanks,
Anders
Yes, this way the event fires just fine!
However, I need to react only to clicks outside the tree items.
Can I translate the position of the click to an item somehow? I've looked at the methods on the treeview without finding any obvious candidates.
(Furthermore this event fires before the 'ordinary' treeview events making it hard to 'hack' it throgh e.g. registering time stamp om last click on items and then checking in the 'raw' click event).
Thanks,
Anders
0
Accepted
Hello Anders,
In your case it is best to use the MouseLeftButtonDownEvent but check the OriginalSource of the event. If it has a parent of type RadTreeViewItem then the event is fired after clicking an item, but if the original source of the event isn't a RadTreeViewItem element, then the click is somewhere in the RadTreeView but outside an item.
I modified the solution to illustrate this approach. Please have a look at it and let em know if it works for you.
All the best,
Tina Stancheva
the Telerik team
In your case it is best to use the MouseLeftButtonDownEvent but check the OriginalSource of the event. If it has a parent of type RadTreeViewItem then the event is fired after clicking an item, but if the original source of the event isn't a RadTreeViewItem element, then the click is somewhere in the RadTreeView but outside an item.
I modified the solution to illustrate this approach. Please have a look at it and let em know if it works for you.
All the best,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Anders
Top achievements
Rank 1
answered on 30 Nov 2011, 01:50 PM
It took me some time before the task crawled back up the list of backlog items ;)
Bu the solution works just fine! Thanks for helping out...
Regrads, Anders, Denmark...
Bu the solution works just fine! Thanks for helping out...
Regrads, Anders, Denmark...