Removing indentation / expander of root nodes

5 posts, 1 answers
  1. Philip
    Philip avatar
    13 posts
    Member since:
    Mar 2015

    Posted 11 Aug 2015 Link to this post

    Hi, I would like to use RadTreeView to display a flat list, but all items have significant indentation.

    I could have used a RadListBox, but since I have the same nodes in a hierarchically TreeView another place in the application, I thought using the same control would be the easiest way to get the same look and functionality (context menu, click etc).

     

    My idea was to set the ItemTemplate of the treeview to a normal DataTemplate or a HierarchicalDataTemplate without specifying ItemSource. It works as I want, except that there is an indention of all the items, leaving a lot of space to the left.

    I have also tried to set the ExpanderStyle to a style containing a collapse template, but it only seems to affect the indentation of child items.

  2. Sia
    Admin
    Sia avatar
    667 posts

    Posted 14 Aug 2015 Link to this post

    Hello Philip,

    Please try to control the items' margin by setting the exposed ItemsIndent property of RadTreeView. If you set the ItemsIndent to 0 all items will be vertically aligned regardless their level. The default indent is 20.
    <telerik:RadTreeView ItemsIndent="0" />

    Let us know if this does not help.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Philip
    Philip avatar
    13 posts
    Member since:
    Mar 2015

    Posted 14 Aug 2015 Link to this post

    Hi, I've tried that but can't see it has an effect on the indentation of the root items.
    I added the following code to my main view :
        <Grid Background="LightGray">
            <telerik:RadTreeView ItemsIndent="0" HorizontalAlignment="Left">
                <telerik:RadTreeViewItem Header="Node A"/>
                <telerik:RadTreeViewItem Header="Node B"/>
            </telerik:RadTreeView>
        </Grid>

     

    Scree shot shows how it looks

  5. Answer
    Sia
    Admin
    Sia avatar
    667 posts

    Posted 17 Aug 2015 Link to this post

    Hello again,

    Unfortunately this space is caused by MinWidth setting in the RadTreeViewItems' default template. The easiest workaround of this issue would be to try setting Padding="-21 0 0 0" to the RadTreeView. This is not the most beautiful solution but in simple scenarios should work and by using it you won't need to set custom style. Please test it in your application (together with the ItemsIndent property) and let me know how it works.

    Regards,
    Sia
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  6. Philip
    Philip avatar
    13 posts
    Member since:
    Mar 2015

    Posted 19 Aug 2015 in reply to Sia Link to this post

    Thank you, that worked :)
Back to Top
UI for WPF is Visual Studio 2017 Ready