Expandable node doesnt show text

2 posts, 0 answers
  1. ss
    ss avatar
    50 posts
    Member since:
    Jun 2010

    Posted 21 Jul 2010 Link to this post

    Hello,

    I have problem with TreeView. I have following code:

    <UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="AdministrationClient.Pages.SettingsManagerPage"
        mc:Ignorable="d"
        xmlns:core="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
        xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
        xmlns:local="clr-namespace:AdministrationClient"
        d:DesignHeight="300" d:DesignWidth="400">
          
        <UserControl.Resources>
              
            <core:HierarchicalDataTemplate x:Key="SettingsTreeNodeTemplate" ItemsSource="{Binding Children}">
                <core:HierarchicalDataTemplate.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Text}" TextWrapping="Wrap" Width="400"/>
                    </DataTemplate>
                </core:HierarchicalDataTemplate.ItemTemplate>
            </core:HierarchicalDataTemplate>
              
        </UserControl.Resources>
          
        <Grid x:Name="LayoutRoot" Background="White">
              
            <Grid.RowDefinitions>
                <RowDefinition Height="22" />
                <RowDefinition />
            </Grid.RowDefinitions>
              
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="500" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
              
            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.ColumnSpan="2" FlowDirection="RightToLeft">
                <telerik:RadButton Name="btnNewSettingsItem" Width="55" Height="22" Content="New" />
                <TextBox Text="{Binding Path=Name}"></TextBox>
            </StackPanel>
              
            <telerikNavigation:RadTreeView 
                Grid.Row="1" 
                Grid.Column="0" 
                Name="rtvSettingsTree" 
                ItemsSource="{Binding SettingsTree}" 
                ItemTemplate="{StaticResource SettingsTreeNodeTemplate}">
            </telerikNavigation:RadTreeView>
              
        </Grid>
          
    </UserControl>


    I dont know why but result of this code is TreeView which is shown in the following picture:
    http://i27.tinypic.com/33f4wgp.png

    Can you please tell my why expandable node doesnt show text?

    My Next question is how to show more than two levels? Just now, TreeView is able to show only 2 levels but I dont know number of levels. Is it possible?

    Thank you very much.

     

     

     

  2. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 22 Jul 2010 Link to this post

    Hello,

    You need to include the <TextBlock Text="{Binding Text}" /> for the outer HierarchicalDataTemplate. This way you are going to define the template for the first tree level. By setting the ItemTemplate property you are defining template for the children (second level).

    I recommend you to take a look of the examples available at
    http://demos.telerik.com/silverlight/#TreeView
    especially the
    http://demos.telerik.com/silverlight/#TreeView/HierarchicalTemplate .

    Regarding your second question you can see the following resource
    http://www.telerik.com/help/silverlight/radtreeview-templating-hierarchical-data-templates.html .

    Best wishes,
    Hristo Milyakov
    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
Back to Top