How to detect that MouseLeftButtonDown is handled in Telerik control internally in the event handler

4 posts, 0 answers
  1. Andie
    Andie avatar
    2 posts
    Member since:
    Mar 2013

    Posted 12 Apr 2013 Link to this post

    Hi Guys,

    I downloaded telerik WPF controls trial version and intended to replace the Microsoft TreeView control in our existing product with Telerik RadTreeView. Currently, I am at the stage of building a prototype to make sure that all of the existing features are still working.

    We have extended RadTreeView and RadTreeViewItem to support various stuff such as ViewModel binding, custom Events and custom Drag and Drop. 

    Our custom drag and drop functionality utilizes the mouse events (i.e. take the mouse position on mouse down, decide whether it triggers a drag operation, end drag on mouse up, etc). 

    For the last couple of days, I've been struggling with the conflicts in handling the MouseButtonDown in our drag and drop subsystem and the MouseButtonDown handle in RadTreeViewItem. Based on the Telerik forum posts, I found that the  MouseLeftButtonDown event is handled internally and if we want to handle the events we have to call AddHandler with the third parameter  set to true.

    I've done the above workaround and able to handle the MouseLeftButtonDown. However because e.Handled is now set to true, all of the controls up in the visual tree that use MouseLeftButtonDown event must handle the MouseLeftButtonDown event through AddHandler call as well. Unfortunately, it is not possible at the moment to change other subsystem to use the AddHandler.

    At the moment, I'm thinking of setting the 'Handled' value to false in the MouseLeftButtonDown handle (from the AddHandler call) and allow the event to be bubbled up. Are there any way to detect that the MouseLeftButtonDown event is handled within the Telerik control? Because our treeviewitem contains a contentcontrol that displays edit button and delete button, if those button are pressed, we still want the Handled property to be true. If there is a guaranteed way to detect whether the MouseLeftButtonDown is handled internally in Telerik control, I could live with it and set the Handled to false when that happen.

    Or, is there a way to configure the Telerik RadTreeViewItem to not set the Handled property to true? 

    PS: I only have one or two weeks trial left. Does anyone know what happen if the trial expires? Can I still continue building the prototype? 

    Kind regards,
  2. Robert
    Robert avatar
    15 posts
    Member since:
    Mar 2013

    Posted 12 Apr 2013 Link to this post

    Could you instead handle the PreviewMouseLeftButtonDown on the TreeView? This event will be fired before the Telerik treeview processes its MouseLeftButtonDown event. If you need to, you can even prevent Telerik's firing the MouseLeftButtonDown event by setting e.Handled = true on your own in the Preview event.
  3. DevCraft R3 2016 release webinar banner
  4. Tina Stancheva
    Tina Stancheva avatar
    3298 posts

    Posted 16 Apr 2013 Link to this post

    Hi Andie,

    There is no straight forward way to identify whether the mouse left button down is handled inside the TreeView or inside button (for example) in its items HeaderTemplate. However, you could identify if the event is handled by the TreeView content by attaching a handler to every element that could handle the mouse (or to the content control containing the buttons). Having that information you could change the Handled property inside TreeView event handlers.

    However, I would like to advice you avoid using this approach. It could be very tricky in certain scenarios and you will probably encounter such cases on a later stage in the development.

    Instead, you could try using the built-in TreeView drag-drop logic. We are currently improving the drag-drop and would highly appreciate and take into account your feedback.

    Please consider my suggestion and let me know if we can further assist you.

    On a side note, regarding your trial expiring, please note that the only difference between the trial and the developer build is that with the evaluation copy you will get a trial message on top of the control once in a while when the control is rendered. Upon replacing the trial dll with the developer dll, the trial message will disappear. But you can definitely keep building your prototype using the trial assemblies. However, you'll also need to consider the fact that the 30-day-trial enables you to send support tickets with 72h response time. Once your trial is over, you'll be able to post your questions only in our forums.


    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Andie
    Andie avatar
    2 posts
    Member since:
    Mar 2013

    Posted 17 Apr 2013 Link to this post

    Thanks Robert and Tina for your responses. 

    Unfortunately, I cannot use the PreviewMouseLeftButtonDown on the TreeView. I still need the MouseLeftButtonDown to be bubbled up for our custom Drag and Drop system. If I set the e.Handled to true on the Preview event, it will prevent the MouseLeftButtonDown to be fired. 

    Also, at this stage, I don't have a plan to use the built-in TreeView drag and drop logic because that requires more changes in other subsystem of our product. I am trying to isolate the Telerik prototype only for the navigation. 

    I ended up using a 'hackish' solution for this issue similar to the one suggested by Tina. In the extended version of RadTreeViewItem, I have to identify if the event is handled by the tree component and re-set the e.Handled to false. Another scenaro is the button, because our tree could have buttons, I also need to check if the OriginalSource of the event is coming from a Button and leave the e.Handled to true if that is the case. 

    Kind Regards,
Back to Top