TreeViewItem height

3 posts, 1 answers
  1. Alexandre
    Alexandre avatar
    8 posts
    Member since:
    Mar 2011

    Posted 09 Aug 2011 Link to this post

    Hello. How can i ovverride radtreeview item height?
    <Style x:Key="RadItemStyle" TargetType="telerik:RadTreeViewItem">
        <Setter Property="MinHeight" Value="10"/>
    </Style>
     
    <telerik:HierarchicalDataTemplate x:Name="ItemTemplate" ItemsSource="{Binding Converter={StaticResource HierarchyConverter}}">
        <telerik:RadTreeViewItem Header="{Binding Name}" Style="{StaticResource RadItemStyle}"/>
    </telerik:HierarchicalDataTemplate>

    this code doesn't work. :(

    Thank's.
  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 12 Aug 2011 Link to this post

    Hello Alexandre,

    When you define the RadTreeView.ItemTemplate you define the way the business data will be displayed inside the RadTreeViewItems. Basically when you bind the RadTreeView control to a business collection, the control's ItemsSource collection is populated and it is used to create RadTreeViewItem containers for each business item from the ItemsSource. So when you set an ItemTemplate it will control the way the business object inside the RadTreeViewItem container is displayed. However, in your case you define a RadTreeViewItem to display the business data, which means that the structure of your tree in any level will contain a RadTreeViewItem inside which a RadTreeViewItem is created to display the business object.

    This is why I wanted to ask you to try this instead:
    <UserControl.Resources>
        <Style x:Key="RadItemStyle" TargetType="telerik:RadTreeViewItem">
            <Setter Property="MinHeight" Value="10" />
        </Style>
     
        <telerik:HierarchicalDataTemplate x:Name="ItemTemplate"
                ItemsSource="{Binding Converter={StaticResource HierarchyConverter}}">
            <TextBlock Text="{Binding Name}"/>
        </telerik:HierarchicalDataTemplate>
    </UserControl.Resources>
    <telerik:RadTreeView ItemTemplate="{StaticResource ItemTemplate}"
            ItemContainerStyle="{StaticResource RadItemStyle}">
    </telerik:RadTreeView>
    Let me know if this works for you.

    Greetings,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
  4. Alexandre
    Alexandre avatar
    8 posts
    Member since:
    Mar 2011

    Posted 17 Aug 2011 Link to this post

    that helps. thanks
Back to Top