Add separator between gallery items?

6 posts, 0 answers
  1. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 05 Jun 2013 Link to this post

    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

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 10 Jun 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 12 Jun 2013 Link to this post

    Thanks for the sample project. I will add this to our project!
  5. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 20 Sep 2013 Link to this post

    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?
  6. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 20 Sep 2013 Link to this post

    Got it working. But I would like the separator to be non-selectable. How?
  7. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 25 Sep 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready