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

ItemContainerStyle with static items

2 Answers 130 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
IT-Support
Top achievements
Rank 2
IT-Support asked on 21 Jun 2015, 01:00 PM

Hi,

I use the RadTreeView with static items - RadTreeViewItems are created in code. I need the tree items to stretch horizontally - so I set the ItemContainerStyle:

<telerik:RadTreeView.ItemContainerStyle>            
   <Style TargetType="telerik:RadTreeViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
    </Style>
</telerik:RadTreeView.ItemContainerStyle>

Unfortunately the style is applied only the root items - like stated in the documentation:

  • "When using ItemContainerStyle with static items, it will get applied only to the direct children of the RadTreeView - the top-level items. If you want their child items to have the same style you have to manually set the ItemContainerStyle property of their parents." (Documentation)

I do not understand how to "manually set the ItemContainerStyle property of their parents". Is there a working example how to use ItemContainerStyle with static items?

Beste regards,
Thomas

2 Answers, 1 is accepted

Sort by
0
Accepted
Milena
Telerik team
answered on 22 Jun 2015, 08:07 AM
Hi Thomas,

Thank you for the detailed explanation.

Indeed, if you set ItemContainerStyle  to the TreeView as an ItemsControl this style will get applied to the root items only (direct children), but not to the nested items. However, I could suggest you using implicit style to the RadTreeViewItem: 
<Style TargetType="telerik:RadTreeViewItem" >
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="Padding" Value="0" />
</Style>

I hope this helps.

Regards,
Milena
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
IT-Support
Top achievements
Rank 2
answered on 22 Jun 2015, 09:41 AM

Hi Milena,

works as intended - thank you very much!

Best regards,
Thomas

Tags
TreeView
Asked by
IT-Support
Top achievements
Rank 2
Answers by
Milena
Telerik team
IT-Support
Top achievements
Rank 2
Share this question
or