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

Binding to class

1 Answer 48 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Oleksandr
Top achievements
Rank 1
Oleksandr asked on 12 Jan 2013, 10:28 AM
Hello,
 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}" />
           
        </DataTemplate 
>

 <telerik:HierarchicalDataTemplate x:Key="ExpanderMenuItemTemplate"


                                          ItemTemplate="{StaticResource PanelBarItemTemplate}"
                                          ItemsSource="{Binding}"
                                          >

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

        </telerik:HierarchicalDataTemplate>


<telerik:RadPanelBar x:Name="Menu"
                                 Grid.Row="2"
                                 ExpandMode="Multiple"
                                 IsEditable="False"
                                 IsExpandOnSingleClickEnabled="True"
                                 ItemTemplate="{StaticResource ExpanderMenuItemTemplate}"
                                 ItemsSource="{Binding ExpanderMenu}"

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 16 Jan 2013, 04:18 PM
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.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PanelBar
Asked by
Oleksandr
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or