This is a migrated thread and some comments may be shown as answers.

Removing indentation / expander of root nodes

4 Answers 430 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 11 Aug 2015, 01:54 PM

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.

4 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 14 Aug 2015, 08:46 AM
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.
0
Philip
Top achievements
Rank 1
answered on 14 Aug 2015, 09:05 AM

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

0
Accepted
Sia
Telerik team
answered on 17 Aug 2015, 01:14 PM
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
0
Philip
Top achievements
Rank 1
answered on 19 Aug 2015, 07:49 AM
Thank you, that worked :)
Tags
TreeView
Asked by
Philip
Top achievements
Rank 1
Answers by
Sia
Telerik team
Philip
Top achievements
Rank 1
Share this question
or