Change GroupHeaderRow AggregateResults text

1 Answer 16 Views
GridView
ANDREW
Top achievements
Rank 1
ANDREW asked on 04 Feb 2022, 11:34 PM

I have this working for properties of the GroupHeaderRow. How do I change the text of the header row?

 Property="Header" Value = "{}{0} test" and  Property="Content" Value = "{}{0} test"  dont seems to do anything.

 public class GroupRowStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            var group = item as QueryableCollectionViewGroup;   
            if (group.count > 1)
            {               
                return BigGroupStyle;
            }
            else
            {
                return SmallGroupStyle;
            }
        }

        public Style BigGroupStyle { get; set; }
        public Style SmallGroupStyle { get; set; }     
    }
<Window.Resources>
        <local:GroupRowStyleSelector x:Key="GroupRowStyleSelector">
            <local:GroupRowStyleSelector.BigGroupStyle>
                <Style TargetType="telerik:GroupHeaderRow">
                     <Setter Property="Background" Value="Red" />
                </Style>
            </local:GroupRowStyleSelector.BigGroupStyle>
            <local:GroupRowStyleSelector.SmallGroupStyle>
                <Style TargetType="telerik:GroupHeaderRow">
                <Setter Property="Background" Value="Yellow" />
                </Style>
            </local:GroupRowStyleSelector.SmallGroupStyle>
        </local:GroupRowStyleSelector>
    </Window.Resources>


1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 09 Feb 2022, 12:50 PM

Hello Andrew,

To achieve the desired result, you can use the GroupHeaderTemplate property like so:

            <local:GroupRowStyleSelector.SmallGroupStyle>
                <Style TargetType="telerik:GroupHeaderRow">
                    <Setter Property="Background" Value="Yellow" />
                    <Setter Property="GroupHeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock Text="{Binding Header, StringFormat={}{0} test}"  />
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </local:GroupRowStyleSelector.SmallGroupStyle>

Please give this a try and let me know if it works for you.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ANDREW
Top achievements
Rank 1
commented on 09 Feb 2022, 06:34 PM

Perfect Dilyan, thank you.
Tags
GridView
Asked by
ANDREW
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or