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

wrap treeview node text

1 Answer 84 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 14 Dec 2011, 10:08 PM
hi

I have a treeview in a stackpanel which can expand or shrink base on some logic. is it possible to limited the maxlenght of the treeview node text so that the text will wrap instread of the horizontal scrollbar shows up when the text is longer than the initial length of the treeview?

Thanks

Kevin

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 19 Dec 2011, 01:49 PM
Hello Kevin,

 You can set MaxWidth of the RadTreeViewitems via Style and then you can use TextBlocks for the Headers. You need to set the TextWrapping property of the TextBlocks to "Wrap", for  example like so:

<Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <Style TargetType="telerik:RadTreeViewItem">
                <Setter Property="MaxWidth" Value="290" />
            </Style>
            <DataTemplate x:Key="itemtemplate">
                <TextBlock TextWrapping="Wrap" Text="{Binding Name}" />
            </DataTemplate>
        </Grid.Resources>
 
        <telerik:RadTreeView x:Name="tree" ItemTemplate="{StaticResource itemtemplate}" Width="300" Background="AliceBlue"/>
 
    </Grid>
You can find this realized in the attached project. Please let us know if it satisfies you. Regards,
Petar Mladenov
the Telerik team

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

Tags
TreeView
Asked by
Kevin
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or