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

RadPanelBar and Binding

5 Answers 413 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Simon Stahl
Top achievements
Rank 1
Simon Stahl asked on 25 Apr 2009, 08:13 PM
Hello

I try to use the RadPanelBar with a Binding as ItemSource, but get an unexpected result. Without binding I would use it like this:
<telerik:RadPanelBar> 
    <telerik:RadPanelBarItem> 
        <telerik:RadPanelBarItem.Header> 
            <Label Content="Header 1"/> 
        </telerik:RadPanelBarItem.Header> 
        <Label Content="Content 1"/> 
    </telerik:RadPanelBarItem> 
</telerik:RadPanelBar> 

That is no problem and looks exactly as expected. But as soon as I use it like this:
<telerik:RadPanelBar Name="AttributeSetPanelBar" ItemsSource="{Binding}"
    <telerik:RadPanelBar.Resources> 
        <DataTemplate DataType="{x:Type wrp:AttributeSet}"
            <telerik:RadPanelBarItem> 
                <telerik:RadPanelBarItem.Header> 
                    <Label Content="{Binding Name}"/> 
                </telerik:RadPanelBarItem.Header> 
                <Label Content="Content"/> 
            </telerik:RadPanelBarItem> 
        </DataTemplate> 
    </telerik:RadPanelBar.Resources> 
</telerik:RadPanelBar> 
and set it's DataContext to a List of objects (in this case AttributeSet), it changes its behaviour! Now the header includes the whole content, and the content itself (the secont Label) is also displayd as Header.
Am I doing something wrong, or is this a bug?

Regards
Simon

5 Answers, 1 is accepted

Sort by
0
Accepted
Bobi
Telerik team
answered on 27 Apr 2009, 03:04 PM
Hello Simon,

If you want to use RadPanelBar with binding then you have to follow these steps:

1.Define some ItemTemplate, e.g.:

<core:HierarchicalDataTemplate x:Key="Entity" ItemsSource="{Binding Items}">
                <TextBlock Text="{Binding Name}" Margin="5 2 5 2" />
 </core:HierarchicalDataTemplate>

2.Avoid setting resources like in your example , it is better to set them in UserControl.Resources for example.

3.Finally add the ItemsSource and ItemTemplate to RadPanelBar:

<telerik:RadPanelBar BorderBrush="#9098a3" BorderThickness="1" Margin="5" x:Name="panelPab" ItemsSource="{StaticResource dsEntity}"
                ItemTemplate="{StaticResource Entity}" />

Please take a look at the following example:
http://demos.telerik.com/silverlight/#PanelBar/DataBinding

You can also take a look at this article:
http://www.telerik.com/help/silverlight/radpanelbar-object-data.html

Let me know if this helps.

Best wishes,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Simon Stahl
Top achievements
Rank 1
answered on 27 Apr 2009, 05:44 PM
Hi Boryana

Thank you for your answer! As I can see, you are using a different HierarchicalDataTemplate from the namespace Telerik.Windows.Controls. I'm using the most actual version of the Telerik.Windows.Controls.dll (version 2009.1.312.35 for WPF), but it seems not to include the class HierarchicalDataTemplate. I searched throught all telerik dlls of my installation, but was not able to locate it. Is it possible, that it is just part of the Silverlight version?

Regards
Simon




0
Simon Stahl
Top achievements
Rank 1
answered on 27 Apr 2009, 07:57 PM
Hi again

OK, I got it now. Thank you for your help!

Regards
Simon
0
Pedro
Top achievements
Rank 1
answered on 22 Nov 2010, 05:48 PM
Hi,

I have the same problem. I cant find the HierarchicalDataTemplate for WPF. What is the namespace?

Best regards,
Gonçalo
0
Tina Stancheva
Telerik team
answered on 22 Nov 2010, 06:38 PM
Hi Gonçalo,

There is a built-in HierarchicalDataTemplate in WPF so you don't need to use any namespace for it. You can have a look at that for more info.

All the best,
Tina Stancheva
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
PanelBar
Asked by
Simon Stahl
Top achievements
Rank 1
Answers by
Bobi
Telerik team
Simon Stahl
Top achievements
Rank 1
Pedro
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or