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

RadTreeView Binding Problem

1 Answer 61 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 27 Apr 2011, 05:40 PM
I have these two classes

public class CustomerModel : _BaseModel
{
    public int CustomerId { get; set; }
    public string CustomerCode { get; set; }
    public string CustomerName { get; set; }
    public List<ProjectModel> Projects { get; set; }
}

and

public class ProjectModel : _BaseModel
{
    public int ProjectId { get; set; }
    public int UserId { get; set; }
    public int CustomerId { get; set; }
    public WarehouseModel PrimaryWarehouse { get; set; }
    public WarehouseModel SecondaryWarehouse { get; set; }
    public ProjectType ProjectType { get; set; }
    public string ProjectName { get; set; }
    public string ProjectNum { get; set; }
    public DateTime Date { get; set; }
    public string Comments { get; set; }
}

and my XAML:

<Window.Resources>
  
    <DataTemplate x:Key="Project">
        <TextBlock Text="{Binding ProjectName}" />
    </DataTemplate>
  
    <HierarchicalDataTemplate x:Key="Customer" 
                                ItemTemplate="{StaticResource Project}"
                                ItemsSource="{Binding Customers}">
        <TextBlock Text="{Binding CustomerName}" />
    </HierarchicalDataTemplate>
  
</Window.Resources>
     

and

<telerik:RadTreeView ItemsSource="{Binding Customers}"
              ItemTemplate="{StaticResource Customer}"/>

When I run it, I see the Customer nodes, but not the Project nodes

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 02 May 2011, 04:25 PM
Hi Kevin,

I guess the reason could be that in XAMl, you have specified the ItemsSource of the HierarchicalDataTemplate incorrectly. I think it should be "Projects" instead of Customers. Please check out the attached project for further reference.

Regards,
Petar Mladenov
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
Tags
TreeView
Asked by
Kevin
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or