Binding to class

2 posts, 0 answers
  1. Oleksandr
    Oleksandr avatar
    2 posts
    Member since:
    Apr 2012

    Posted 12 Jan 2013 Link to this post

     i have a simple model.

     class A
        public string Title {get;set;}
        public string Content {get;set;}

    in VM i make a List<A> ExpanderMenu and bind it to the RAdPanelBar, Title is binding ok,
    but when i click to expand the PanelBar its doesn't expand.
    Who to expand it???

    <DataTemplate x:Key="PanelBarItemTemplate">
                    <TextBlock Text="{Binding Content}" />

     <telerik:HierarchicalDataTemplate x:Key="ExpanderMenuItemTemplate"

                                              ItemTemplate="{StaticResource PanelBarItemTemplate}"

                <TextBlock Text="{Binding Title}" />


    <telerik:RadPanelBar x:Name="Menu"
                                     ItemTemplate="{StaticResource ExpanderMenuItemTemplate}"
                                     ItemsSource="{Binding ExpanderMenu}"
  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 16 Jan 2013 Link to this post

    Hi Oleksandr,

    The RadPanelBarItems derive from the RadTreeViewItem class thus both controls expect a hierarchical structure. This means that the RadPanelBarItem exposes Items/ItemsSource properties and the data item that describes the RadPanelBarItem is expected to have the same structure. But I noticed that your class A implementation doesn't have a collection of items to be displayed inside each RadPanelBarItem Items property.

    Usually the RadPanelBar control is used to display detailed list of information for the root-level items as demonstrated in this tutorial.

    But in case you need to display a flat collection of data in the RadPanelBar control, you can use a -converter when you bind the ItemsSource property of the first-level items' HierarchicalDataTemplate as demonstrated in the attached sample.

    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top