How to stretch item horizontally

5 posts, 1 answers
  1. Henk
    Henk avatar
    113 posts
    Member since:
    Apr 2006

    Posted 09 Sep 2010 Link to this post


    In a RadTreeview I want to display an optional Textbox in each item.
    I used a HierarchicalDataTemplate attached to the RadTreeview.
    Now the width of the TextBox is equal to the width of the (header)text shown in the TextBlock.
    I want to stretch the width of the TextBox to fill up the width of the whole item in the Treeview.
    HorizontalAlignment= "Stretch" in the HierarchicalDataTemplate does not work.
    Has anyone an idea to fix this?

       <telerik:HierarchicalDataTemplate x:Key="ItemTemplate" ItemsSource="{Binding Converter={StaticResource HierarchyConverter}}"
                                              telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}">
                <Grid x:Name="HeaderRow" Width="Auto" HorizontalAlignment="Stretch">
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*"/>
                    <TextBox Text="{Binding OmsText, Mode=TwoWay}" Visibility="{Binding OmsVisiblity, Mode=TwoWay}" HorizontalAlignment="Stretch" Height="Auto" TextWrapping ="Wrap" Grid.Row="1" />
                    <TextBlock Text="{Binding Text, Mode=TwoWay}" HorizontalAlignment="Stretch"/>
  2. Answer
    Kiril Stanoev
    Kiril Stanoev avatar
    1508 posts

    Posted 14 Sep 2010 Link to this post

    Hello Henk,

    You need to set HorizontalContentAlignment to Stretch of each RadTreeViewItem. To do that, you can set an ItemContainerStyle of RadTreeView:

            <Style TargetType="telerik:RadTreeViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />

    Let me know if it helps.

    Kind regards,
    Kiril Stanoev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Henk
    Henk avatar
    113 posts
    Member since:
    Apr 2006

    Posted 15 Sep 2010 Link to this post

    Thanks, the item stretches nicely now!
  5. saw
    saw avatar
    29 posts
    Member since:
    Jun 2014

    Posted 10 Oct 2014 in reply to Kiril Stanoev Link to this post

    I make value to "Left", but items not align to left side of the tree. Items are still keep small (considerable) space in left side of the tree.
  6. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 13 Oct 2014 Link to this post

    Hi Saw,

    Since this is a very old thread, is it possible for you to open a new support ticket with more details about your specific scenario ? We are not exactly sure what you wish to achieve. Thank you in advance for your cooperation.

    Petar Mladenov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top
DevCraft banner