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

Add separator between gallery items?

5 Answers 137 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Kristoffer
Top achievements
Rank 1
Kristoffer asked on 05 Jun 2013, 01:10 PM

I have a RadPanelBar with galleries of gallery items. The binding is simple:

ItemTemplate="{StaticResource ToolboxTemplate}"

ItemContainerStyle="{StaticResource PanelBarItemFirstLevelStyle}"
ItemsSource="{Binding HierarchicalGalleryItems}"

 

And in the Viewmodel:
public ObservableCollection<Gallery> HierarchicalGalleryItems

This collection is filled with instances of Gallery which, in turn, have multiple instances of GalleryItem. I want to put a separator between some of these gallery items. How can this be done?

Thanks

5 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 10 Jun 2013, 11:33 AM
Hello Kristoffer,

As far as I understand, you have data binding scenario and you want to define some separator between your data items. The RadPanelBar does not provide such functionality out of the box.

However, you can achieve your requirement by adding items to your business collection. Those items can be visualized like separators by applying different DataTemplate to them. For your convenience I implemented this approach in the attached project. Please note that the ItemTemplateSelector of the HierarchicalDataTemplate is used.

Take a look at the solution and let me know if you have any other questions.

Regards,
Pavel R. Pavlov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristoffer
Top achievements
Rank 1
answered on 12 Jun 2013, 07:47 AM
Thanks for the sample project. I will add this to our project!
0
Kristoffer
Top achievements
Rank 1
answered on 20 Sep 2013, 08:57 AM
Your sample works. However, I tried adding a data template selector in my project and it seems the ItemTemplate is never applied! My panel items simply show the class name.

In my HierarchicalDataTemplate, I set the ItemTemplateSelector to my data template selector. When debugging, I can see that it has successfully assigned the data templates and it does indeed return the correct one. Still, the template is not applied. If I, instead, explicitly set the ItemTemplate to the data template returned by my data template selector, it works!

What could be the cause of this?
0
Kristoffer
Top achievements
Rank 1
answered on 20 Sep 2013, 03:08 PM
Got it working. But I would like the separator to be non-selectable. How?
0
Pavel R. Pavlov
Telerik team
answered on 25 Sep 2013, 06:28 AM
Hello Kristoffer,

As far as I understand you need to disable the visual states of the RadPanelBarItems that are marked as separators. In order to do so you need to customize the default ControlTemplate of the RadPanelBarItem control.

In order to do so you can define an ItemContainerStyleSelector in your HierarchicalDataTemplate. Furthermore, you can define two styles. The first one will define only the HeaderTemplate property and the second one will define only Template property.

For your convenience I changed the implementation of the previously attached project. Please take a look at it and let us know if you need any further assistance.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
PanelBar
Asked by
Kristoffer
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Kristoffer
Top achievements
Rank 1
Share this question
or