RadPanelBar with simple items

5 posts, 0 answers
  1. kfir ANKORI
    kfir ANKORI avatar
    6 posts
    Member since:
    Apr 2010

    Posted 23 Dec 2010 Link to this post

    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!
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 23 Dec 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. kfir ANKORI
    kfir ANKORI avatar
    6 posts
    Member since:
    Apr 2010

    Posted 23 Dec 2010 Link to this post

    Hey, Tina.

    Thanks for your quick reply.

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

    Thanks!
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 27 Dec 2010 Link to this post

    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
  6. kfir ANKORI
    kfir ANKORI avatar
    6 posts
    Member since:
    Apr 2010

    Posted 27 Dec 2010 Link to this post

    Thanks!
Back to Top
UI for WPF is Visual Studio 2017 Ready