IsExpandOnDblClickEnabled="False" doesn't work

6 posts, 1 answers
  1. Roman
    Roman avatar
    5 posts
    Member since:
    Jul 2012

    Posted 28 Aug 2012 Link to this post

    Hi!

    By default treeview expands nodes by double clicking on items.

    I would like to change this, so that single click expands nodes and double click does nothing.
    I used this in xaml (in RadTreeView control): 

    IsExpandOnDblClickEnabled="False"
    IsExpandOnSingleClickEnabled="True"

    While single click now works, the problem is, that double click stil expands and collapses nodes. 

    Here is some additional info:

    Silverlight version: 5.0
    OS: Win7 x64
    Browser: IE9 v9.0.8112.16421 or Chrome v21.0.1180.83
    Telerik: 2012.2.725.1050 (runtime version: v4.0.30319)
    Preffered language VB.NET

    update:
    I just checked example at http://demos.telerik.com/silverlight/#TreeView/CheckBoxLinesSupport 
    and it's the same situation - if you select SingleClick at "Expand on click" options, double click still expand/collapse node...

    Can someone confirm, that this is a bug in this control?

    Roman
  2. Answer
    Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 29 Aug 2012 Link to this post

    Hello Roman,

    The logic you want to use is a custom one and it is not implemented in the RadTreeView, because a double click always contains a single one.

    There is a workaround that I can suggest to you. First both properties IsExpandOnDblClickEnabled and IsExpandOnSingleClickEnabled should be set to "False". And second, you should handle the Click event and wait (using a DispatcherTimer for example) to see whether there would be second click in a short interval of time and if so - do noting, otherwise expand/collapse the RadTreeView.

    Regards,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Roman
    Roman avatar
    5 posts
    Member since:
    Jul 2012

    Posted 29 Aug 2012 Link to this post

    Hello, Stefan!

    Thanks for your tip. I have done as you have suggested and now it works as it should.

    Have a nice day,
    Roman
  5. Anjani
    Anjani avatar
    21 posts
    Member since:
    Mar 2011

    Posted 20 Sep 2012 Link to this post

    Hi Stefan,
    Im working with radtreeview in Silverlight. Version of telerik controls : 2012.2.725.1050. Radtreeview supports these properties :
    IsExpandOnSingleClickEnabled and IsExpandOnDblClickEnabled 
    to control epansion and collapsing of nodes. My requirement is that I want to disable node expand and collapse on 'Enter' key press. Is this functionality supported yet ? Can you suggest anything for this requirement ?

    Awaiting your response
    Thanks
    Anjani Jaswal
  6. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 24 Sep 2012 Link to this post

    Hi Anjani,

    The behavior you want is supported and here is my suggestion how to implement it.

    First you have to get the pressed key from the RadTreeViewItem's KeyDown event. But because the RadTreeView handles this event you should attach a handler listening to handled events. The best way to do it is to attach a KeyDown (handled true) handler in the ItemPrepared event of the TreeView. After that you can use the pressed key as a condition in an if statement in the PreviewExpand/Collapse events to check whether the pressed key is "Enter". On the other hand "Enter" can be used when editing a node and it is a good idea to add a second condition in this if statement - IsEditing != true. And finally if both condition are fulfilled then you just have to handle the event.

    You can check this implementation in the project I have attached.

    Regards,
    Stefan
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  7. Anjani
    Anjani avatar
    21 posts
    Member since:
    Mar 2011

    Posted 25 Sep 2012 Link to this post

    Hi Stefan,

    Thanks a ton for your suggestion.. This is exactly what I needed..

    Regards
    Anjani
Back to Top
DevCraft banner