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

RadPanelBar +DataTemplate

2 Answers 159 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Daniel Varrin
Top achievements
Rank 1
Daniel Varrin asked on 15 Dec 2009, 06:57 PM
Hi,

I'm trying to use the RadPanelBar control for a binding source which contains a list of lists. I mean I have an object containing a list of sections, and each section contains a list of commands.

I'm creating the control using this XAML:

<

 

 

telerikNavigation:RadPanelBar ItemsSource="{Binding Path=Sections}"

 

 

 

    ItemTemplate="{StaticResource SectionsTemplate}"/>

And I have the two following templates:

 

 

 

 

 

<

 

 

DataTemplate x:Key="CommandsTemplate">

 

 

 

 

 

 

 

 

    <StackPanel Orientation="Vertical" Margin="5">

 

 

 

 

 

 

 

 

        <TextBlock Margin="2,6">

 

 

 

 

 

 

 

 

            <Hyperlink Command="{Binding Path=Command}">

 

 

 

 

 

 

 

 

                <TextBlock Text="{Binding Path=DisplayName}" />

 

 

 

 

 

 

 

 

            </Hyperlink>

 

 

 

 

 

 

 

 

        </TextBlock>

 

 

 

 

 

 

 

 

    </StackPanel>

 

 

 

 

 

 

 

 

</DataTemplate>

 

 

 

 

 

 

 

 

 

 

 

 

 


<
DataTemplate x:Key="SectionsTemplate">

 

 

 

 

 

 

 

 

    <telerikNavigation:RadPanelBarItem ItemsSource="{Binding Path=Commands}" ItemTemplate="{StaticResource CommandsTemplate}">

 

 

 

 

 

 

 

 

        <telerikNavigation:RadPanelBarItem.Header>

 

 

 

 

 

 

 

 

            <TextBlock Text="{Binding Path=SectionName}" />

 

 

 

 

 

 

 

 

        </telerikNavigation:RadPanelBarItem.Header>

 

 

 

 

 

 

 

 

    </telerikNavigation:RadPanelBarItem>

 

 

 

 

 

 

 

 

</DataTemplate>

The result is that there is like an other control in the sections bars, and I have to click on it (the arrow is not working) to see the list of commands, but instead of the commands being simple links, they appear as a RadPanelBar, with an arrow on the right which is doing nothing.

What am I doing wrong?

Best regards,
Daniel Varrin

 

2 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 19 Dec 2009, 08:48 AM
Hello Daniel,

The reason why you experience this issue is because you use a RadPanelItem inside a DataTemplate. For this scenario it is best to use a HierarchicalDataTemplate. I have modified your XAML and I have attached a sample project demonstrating how to use HierarchicalDataTemplate. Have a look at it and let me know if something needs further clarification. Additionally, you can take a look at this help article, as it explains how to use HierarchicalDataTemplate to populate a TreeView. The principle is the same since both RadPanelBar and RadTreeView are HeaderedItemsControls.

Greetings,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel Varrin
Top achievements
Rank 1
answered on 19 Dec 2009, 09:50 PM
Hi Kiril,

Thank you very much for you answer and for the example. It is working all fine now with a HierarchicalDataTemplate :-)))

Daniel
Tags
PanelBar
Asked by
Daniel Varrin
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Daniel Varrin
Top achievements
Rank 1
Share this question
or