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

GridView GroupStyle

1 Answer 114 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Marcel asked on 29 Mar 2014, 10:53 AM

I have bought the Terelik DevCraft package and now I am working to convert some of my controls to Telerik controls.
I started with a DataGrid, this DataGrid has a GroupStyle and I am trying to  apply this groupstyle to my new GridView.
The groupstyle has a converter which checks if the group contains more than 1 items, then it wil create a groupbox around the item with a header which specificies to which order the items belong. When there is only 1 item in the group there is no groupbox and no header.

I want to have the same functionality in my new GridView, my new GridView already group the items by ordernumber in an expander, I am now a bit lost on how to style the header so it shows the same information as my former groupstyle. Because of the expander of the GridView its not necessary to use a groupbox anymore.

My old groupstyle:

                                <Style TargetType="{x:Type GroupItem}">
                                        <DataTrigger Binding="{Binding Path=Items, Converter={StaticResource groupDocumentsConverter}}" Value="True">
                                            <Setter Property="Template">
                                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                                        <GroupBox Margin="2,20,2,25">
                                                                    <StackPanel VirtualizingStackPanel.IsVirtualizing="True" Orientation="Horizontal" DataContext="{Binding Path=DataContext, 
                                                                                    RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupItem}}">
                                                                        <TextBlock Text="Order " FontWeight="Bold" />
                                                                        <TextBlock Text="{Binding Path=Name, StringFormat='{}{0:000000}'}" FontWeight="Bold"/>
                                                                        <TextBlock Text=" - " FontWeight="Bold"/>
                                                                        <TextBlock Text="{Binding Path=ItemCount}" FontWeight="Bold"/>
                                                                        <TextBlock Text=" document(s)" FontWeight="Bold"/>
                                                            <ItemsPresenter />

I searched in the documentation on internet but wasnt able to find a good solution.
The documentation points me to altering the template using Blend, but I think a faster solution should be possible?

Any help would be greatly appreciated.



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 02 Apr 2014, 03:36 PM
Hello Marcel,

If you want to style conditionally RadGridView group rows, you can use GroupRowStyleSelector as shown in this online demo. The same example is available in your local copy of WPF demos. Extended example for using a style selector can be found in the RowStyleSelector help article. The approach for the group row will be similar. Also, if you want to predefine the template of RadGridView's group row template, you can use the GroupHeaderTemplate property:
<telerik:RadGridView Grid.Row="0"
     ItemsSource="{Binding Clubs}"

I hope this information helps.


Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question