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

ContentTemplate for items in RadPanelBar

6 Answers 124 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Miłosz Cechnicki
Top achievements
Rank 1
Miłosz Cechnicki asked on 29 May 2014, 12:26 PM
Helo,

i want bind ItemsSource to RadPanelBar and define template for item header and item content. I know  that to define header template I must use ItemTemplate property, but I don't know how to define content template. In RadTabControl I have ContentTemplate property but no in RadPanelBar. I don't want implement hierarchical structure (ItemsSource is flat one level list). Could you explain me how can i do this?

6 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 31 May 2014, 10:33 AM
Hello,

When working with the RadPanelBar control you need to know that it actually derives from the RadTreeView control. It also inherits the hierarchical structure of the RadTreeView. This is why it is important to understand that the ItemHeader is actually a RadTreeViewItem with custom style applied. And the Items are also RadTreeViewItems with another style applied.

For more information about how you can bind the control you can take a look at our QSF demo project. I hope this will help you.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Miłosz Cechnicki
Top achievements
Rank 1
answered on 02 Jun 2014, 05:16 AM
Not exactly. I could define something like this:

<telerik:RadPanelBar>
    <telerik:RadPanelBarItem Header="My header">
        <StackPanel>
            <TextBlock Text="My" />
            <TextBlock Text=" content" />
        </StackPanel>
    </telerik:RadPanelBarItem>
</telerik:RadPanelBar>

And I could define HeaderTemplate for item (using property HeaderTemplate for RadPanelBarItem or using property ItemTemplate for RadPanelBar). As you can see I could define content for RadPanelBarItem (StackPanel with TextBlocks). I want define template for content, but I don't know how.

Example:
I have flat (one level) collection of persons (with properties Name, Surname, Age, etc.). And I want bind this collection to RadPanelBar and I want to see in header Name of person and when I expand item I want to see other properties (Surname, Age, etc.).

Thanks for your help.
0
Pavel R. Pavlov
Telerik team
answered on 02 Jun 2014, 09:45 AM
Hi,

In that particular scenario the StackPanel will be wrapped in a RadPanelBarItem which will be styled with a different style. You can check this with a XAML inspecting tool.

However, in order to create the hierarchy that the RadPanelBar control needs, you can use a HierarchicalDataTemplate. For your convenience I prepared a sample project demonstrating this approach. Please take a look at it and let me know if you need any further assistance.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Miłosz Cechnicki
Top achievements
Rank 1
answered on 02 Jun 2014, 12:36 PM
Ok, I understand this. So in my example better way is to use ItemsControl and define ItemTemplate with Expander (with binding in Header and Content).

Thanks for your help.
0
vimal
Top achievements
Rank 1
answered on 04 Aug 2015, 06:29 AM
[quote]Pavel R. Pavlov said:Hi,

In that particular scenario the StackPanel will be wrapped in a RadPanelBarItem which will be styled with a different style. You can check this with a XAML inspecting tool.

However, in order to create the hierarchy that the RadPanelBar control needs, you can use a HierarchicalDataTemplate. For your convenience I prepared a sample project demonstrating this approach. Please take a look at it and let me know if you need any further assistance.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 

[/quote]

 

Hi 

I was able to follow the implementation of RadPanelBar with HierarchicalDataTemplate. In this case I want to have Header style for RadPanelBarItem. How can i achieve that?

 Thanks

Vimal

0
Evgenia
Telerik team
answered on 06 Aug 2015, 11:25 AM
Hello vimal,

You can use the explanation that Pavel provided in his previous posts stating that RadPanelBar is like RadTreeView - the ItemHeader is actually a RadPanelBarItem with custom style applied. And its child Items are also RadPanelBarItems with another style applied. Having this in mind you can apply implicit style that targets RadPanelBarItem that will apply on all items. To distinguish those that are second level items (children of root items) you can apply ItemContainerStyle to the HierarchicalDataTemplate again with TargetType RadPanelBarItem. I attached a modified version of Pavel's sample to demonstrate how you might apply two different Foreground-s on root and child items based on the styles I described.

P.S. Please add reference to NoXAML binaries to run the sample and don't forget to reference Telerik.Windows.Themes.OfficeBlack assembly as well. You might read more about the separation of XAML and NoXAML binaries and why we ship them in this help article.

I hope this information helps.

Regards,
Evgenia
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PanelBar
Asked by
Miłosz Cechnicki
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Miłosz Cechnicki
Top achievements
Rank 1
vimal
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or