Disabling and Hiding Expander in Tree control

6 posts, 0 answers
  1. Balaram Barange
    Balaram Barange avatar
    28 posts
    Member since:
    Apr 2009

    Posted 18 Sep 2009 Link to this post

    Hi,
    In our application we have a requirement in which we want to show a tree hierarchy in expanded state, we should not able to collapse it and no expander be shown.
    How can we do it using RadTreeView ?

    Regards,
    Balaram Barange


  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 18 Sep 2009 Link to this post

    Hi Balaram Barange,

    You have two options
    1. Use the PreviewExpanded event and handle it if you want to stop the expand.
    2. Use a StyleSelector and modify the Style for the expander by using the ExpanderStyle property and set the IsEnabled property to false.

    Best wishes,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
  4. William
    William avatar
    15 posts
    Member since:
    Jun 2010

    Posted 05 Jul 2010 Link to this post

    Hi,
    I have a related question...What would be the best way to disable and hide the expander for the root item only?
    Thanks,
    Pete
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 08 Jul 2010 Link to this post

    Hi William,

    You can use the ItemContainerStyleSelector property to apply a different style for the root items, where the expander is collapsed:
     
    <ToggleButton x:Name="Expander" Background="{TemplateBinding Background}" IsTabStop="False" Visibility="Collapsed"/>

    I prepared a sample project illustrating this approach. Please take a look at it and let me know if it works for you.

    All the best,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. William
    William avatar
    15 posts
    Member since:
    Jun 2010

    Posted 14 Jul 2010 Link to this post

    Hi Tina,
    Thanks for taking the time to make the example. It works as advertised and I understand what you're doing to make it happen.
     
    It feels a little like overkill to have to recreate the 150 line RadTreeViewItem style resource just in order to change a single line and I have a funny feeling that I might have to create a style resource for each theme (but I may be wrong about that). Thats something I'd really prefer to stay away from because if the theme ever changed then I'd have to redefine the resource. Its not that I couldn't do it but its more about dealing with the maintenance issue.  I guess what I'm getting to is that it sure seems like a lot of work and that it would be nice to have an 'ExpanderVisibility' type of property to make it much easier to do.  For my project, designing the treeview control so that the root item doesn't have the expander is a minor usability concern. Its minor enough to where if it tkes a lot of code to support or brings up maintenance issues then I'd just skip it.

    I appreciate your help,
    Pete
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 19 Jul 2010 Link to this post

    Hello William,

    Thank you for the feedback. Actually we have logged controlling the visibility of the expander as a feature request in our PITS where you can vote for it. And if the feature gathers enough popularity, we will definitely consider implementing it.

    Any additional comments on the matter are highly appreciated.

    Greetings,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready