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

RadPanelBar with simple items

4 Answers 138 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
kfir ANKORI
Top achievements
Rank 1
kfir ANKORI asked on 23 Dec 2010, 05:37 PM
Hello, i want my RadPanelBar to be binded to a list of items, each item has two properties:
header and body
the body is a simple object.
hod do i put it inside the single panel when it is opened?
do i must use HierarchicalDataTemplate ???

i also wanted to get events for each panel when it is expanded. for this i used ItemContainerStyle, but this was applied to the items inside the panel as well. why?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 23 Dec 2010, 07:08 PM
Hi kfir ANKORI,

Yes you should use a HierarchicalDataTemplate to display a hierarchy of items. You can see more info about that here. However, you can define different ItemTemplates for the root and child items. The child items' ItemTemplate can be defined in the roots' PanelBarItems HierarchicalDataTemplate like so:
<telerik:HierarchicalDataTemplate x:Key="PanelBarItemTemplate"
                  ItemsSource="{Binding Children}"
                  ItemTemplate="{StaticResource ChildTemplate}">
    <TextBlock Text="{Binding Header}" />
</telerik:HierarchicalDataTemplate >

This will allow you to specify a DataTemplate for the object you want to display inside each RadPanelBarItem.

Also, whenever a RadPanelBarItem is expanded, the RadPanelBar Expanded() event is fired, so you can handle it to implement your logic.

I hope this info will help you.

Regards,
Tina Stancheva
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
kfir ANKORI
Top achievements
Rank 1
answered on 23 Dec 2010, 08:09 PM
Hey, Tina.

Thanks for your quick reply.

is there any way to specify different ItemContainerStyle for the the root items and sub items?

Thanks!
0
Petar Mladenov
Telerik team
answered on 27 Dec 2010, 02:02 PM
Hello kfir ANKORI,

Yes, you can do like so:
<Window.Resources>
       <Style x:Key="TopLevelStyle" TargetType="{x:Type telerik:RadPanelBarItem}">
           <Setter Property="Foreground"   Value="Aqua" />
       </Style>
       <Style x:Key="SecondLevelStyle" TargetType="{x:Type telerik:RadPanelBarItem}">
           <Setter Property="Foreground" Value="Red" />
       </Style>
       <DataTemplate x:Key="SecLevelTemplate" >
           <TextBlock Text="{Binding Name}" />
       </DataTemplate>
       <HierarchicalDataTemplate x:Key="ReportGroupTemplate"
                                 ItemsSource="{Binding reportViewModelSingleList}"  
                                 ItemTemplate="{StaticResource SecLevelTemplate}"
                                 ItemContainerStyle="{StaticResource SecondLevelStyle}">
           <TextBlock Text="{Binding Name}"  />
       </HierarchicalDataTemplate>
   </Window.Resources>
   <Grid>
       <telerik:RadPanelBar x:Name="Panelbar" 
                            ItemTemplate="{StaticResource ReportGroupTemplate}"  
                            ItemContainerStyle="{StaticResource TopLevelStyle}">          
       </telerik:RadPanelBar>
   </Grid>
Feel free to ask if you need further info.

Best wishes,
Petar Mladenov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
kfir ANKORI
Top achievements
Rank 1
answered on 27 Dec 2010, 03:07 PM
Thanks!
Tags
PanelBar
Asked by
kfir ANKORI
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
kfir ANKORI
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or