2 posts, 1 answers
  1. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 11 Jan 2013 Link to this post

    I have GroupHeaderContentTemplateSelector working for my control. I am currently showing null groups as well.

    My template basically colors in the background of the resource to black and sets the font to white. However, the empty group that appears does not take on this template.

    1) How can I apply the template to the null group?
    2) How can I place custom text in as the header for the null group?


  2. Answer
    Yana avatar
    5037 posts

    Posted 16 Jan 2013 Link to this post

    Hello Tim,

    I would suggest to create a custom GroupHeaderContentTemplateSelector as explained here and add a DataTemplate for the NullGroups:

    public class CustomGroupHeaderContentTemplateSelector : ScheduleViewDataTemplateSelector
        public DataTemplate HorizontalTemplate { set; get; }
        public DataTemplate VerticalTemplate { set; get; }
        public DataTemplate NullGroupTemplate { set; get; }
        public override DataTemplate SelectTemplate(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition)
            CollectionViewGroup cvg = item as CollectionViewGroup;
            if (cvg != null)
                if (cvg.Name == null)
                    return this.NullGroupTemplate;
                if (activeViewDeifinition.GetOrientation() == Orientation.Vertical)
                    return this.HorizontalTemplate;
                    return this.VerticalTemplate;
            return base.SelectTemplate(item, container, activeViewDeifinition);

    and in XAML:

    <example:CustomGroupHeaderContentTemplateSelector x:Key="CustomGroupHeaderContentTemplateSelector">
                <Border Background="Red">
                    <ContentPresenter Content="{Binding FormattedName}" Height="16" Margin="4" />
                <telerikPrimitives:LayoutTransformControl VerticalAlignment="Top">
                        <RotateTransform Angle="-90" />
                    <ContentPresenter Content="{Binding FormattedName}" Margin="4" Height="16" />
                <Border Background="Red">
                    <TextBlock Text="Without resource" Height="16" Margin="4" />

    Hope this helps.

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top