Can't bind to hierarchical object data

4 posts, 1 answers
  1. Ryan
    Ryan avatar
    33 posts
    Member since:
    May 2009

    Posted 06 Jul 2009 Link to this post

    Hi

    I've been following this example for binding to object data.

    However I can't specify the <DataTemplate>.

    Instead I get the message "Property 'VisualTree' does not support values of type 'DataTemplate'".

    What am I doing wrong?
    <UserControl x:Class="ReportDistribution.Client.ReportMgr.WpfApp.UserControls.ReportMenuPanel" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
        Height="300" Width="270"
        <UserControl.Resources>         
            <ItemsControl> 
                <ItemsControl.ItemTemplate> 
                    <HierarchicalDataTemplate x:Key="Entity" ItemsSource="{Binding ClientReport}">                    
                        <DataTemplate> 
                            <TextBlock Text="{Binding Name}"></TextBlock> 
                        </DataTemplate> 
                    </HierarchicalDataTemplate> 
                </ItemsControl.ItemTemplate> 
            </ItemsControl>    
        </UserControl.Resources> 
        <Grid>         
            <Grid.RowDefinitions> 
                <RowDefinition Height="35"></RowDefinition> 
                <RowDefinition></RowDefinition
            </Grid.RowDefinitions> 
            <Grid.ColumnDefinitions> 
                <ColumnDefinition></ColumnDefinition
            </Grid.ColumnDefinitions> 
            <Border Grid.Row="0" BorderBrush="Black" BorderThickness="1"
                <Border.Background> 
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"
                        <GradientStop Color="#ADCFFF" /> 
                        <GradientStop Color="#599BFF" Offset="1"></GradientStop> 
                    </LinearGradientBrush> 
                </Border.Background> 
            </Border> 
            <TextBlock Grid.Row="0" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Margin="5">Reports</TextBlock> 
            <Border Grid.Row="1" BorderBrush="Black" BorderThickness="1,0,1,1"
                <Border.Background> 
                    <SolidColorBrush Color="White" /> 
                </Border.Background> 
            </Border> 
            <telerik:RadPanelBar x:Name="reportMenuPanelBar" Grid.Row="1" Margin="1,0,1,1" ItemTemplate="{StaticResource Entity}" ItemsSource="{Binding}"
                 
            </telerik:RadPanelBar> 
                     
        </Grid> 
    </UserControl> 



  2. Answer
    Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 07 Jul 2009 Link to this post

    Hello Ryan,

    Please take a look at the attached project. I prepared it for you as a simple demonstration of how to bind a RadPanelBar control to a collection of objects. Please let me know if it helps.

    Greetings,
    Tihomir Petkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ryan
    Ryan avatar
    33 posts
    Member since:
    May 2009

    Posted 08 Jul 2009 Link to this post

    Thank you Tihomir.

    You should update the help because the xaml is wrong.


  5. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 09 Jul 2009 Link to this post

    Hello Ryan,

    We will update the help article ASAP. Thank you for reporting this issue. I updated your Telerik points.

    Best wishes,
    Tihomir Petkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top