9 Answers, 1 is accepted
Hello Marco,
To achieve this you need to provide a custom template for the GridViewGroupPanel element.
Here is some sample xaml:
<Grid> |
<Grid.Resources> |
<Style TargetType="telerik:GridViewGroupPanel"> |
<Setter Property="Template"> |
<Setter.Value> |
<ControlTemplate TargetType="telerik:GridViewGroupPanel"> |
<Grid Background="Transparent"> |
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0.6" /> |
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> |
<WrapPanel Margin="-2,0,0,0"> |
<ItemsPresenter x:Name="itemsPresenter" Margin="0,10,10,0" /> |
</WrapPanel> |
<TextBlock Text="Modified text goes here..." Margin="10, 0, 0, 0" IsHitTestVisible="False" VerticalAlignment="Center" /> |
</Grid> |
</ControlTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
</Grid.Resources> ... |
Here I have added a style for the GridViewGroupPanel. The style is added to the resources of the root element of my window. It sets the template of the GridViewGroupPanel to a custom one (with modified text).
Greetings,
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
When I use your code and when I group by a column, the rectangle containing the column have a transparent background.
The problem is I don't see the column name, it's confused with the "TextBlock". How I can do?
Thanks
P.S. : Sorry for English, I'm French !
Hello Jérôme Gaborieau,
I am not sure what exactly is the trouble. I guess both texts overlap and make caption unreadable ? .
In such case I would recommend to set margins to the textblock in the template provided , so that the text is moved up or down and thus stop overlapping with the items.
<TextBlock Text="Modified text goes here..." Margin="10, 0, 0, 0" ...
Here you can try setting different values of the margins. Hope this will fix the problem.
Kind regards,
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
But, can I change the background color of the column's name or hide the text when I sort by a column?
Thanks
Jérôme
I guess you are trying to localize the RadGridView ?
When localized , this text will hide automatically . Here is a detailed description on how you can localize the RadGridView texts ( including the Group Header) .
All the best,
Pavel Pavlov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I'm looking at adding this to the ControlTemplate inside a Resource dictionary and implement with XAML binding that way the individual UI's don't have to be touched, that way I can add the ability for the users to turn on/off filtering as they wish so that I can conserved the space taken up by the filtering Icon (LOTS of columns on some grids).
In this case, by default my RadGridView Style is setting IsFilteringAllowed = False and I'd like to bind the checkbox on the GridViewGroupPanel and this property to that on property changed I could turn on filtering???? (At least that's my hope....)
Byron
It is absolutely possible!
Please have a look at the attached project.
In case you have troubles adapting this to your scenario just let me know.
Best wishes,
Pavel Pavlov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thank you for the example code, which I have copied into my project. But, whilst the default text "Group header etc" is replaced by "Grouped by:" when you drag a column header to the panel, with your example this is not the case, and the column label is ovelapping the new header text which is not replaced by anything else such as "Group by:"
How can I make the customised text dispapear when you are grouping - just like it does by default?
Here is my xaml:
<Style TargetType="telerik:GridViewGroupPanel"> |
<Setter Property="Template"> |
<Setter.Value> |
<ControlTemplate TargetType="telerik:GridViewGroupPanel"> |
<Grid Background="Transparent"> |
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0.6" /> |
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> |
<WrapPanel Margin="-2,0,0,0"> |
<ItemsPresenter x:Name="itemsPresenter" Margin="0,20,3,0" /> |
</WrapPanel> |
<StackPanel Orientation="Vertical" Margin="10,10,0,0" > |
<TextBlock Text="Logged Events" FontFamily="Times New Roman" FontSize="20" IsHitTestVisible="False" VerticalAlignment="Center" /> |
<TextBlock Text="Drag a column header and drop it here to group by that column" Opacity="0.5" FontFamily="Arial" FontSize="10" IsHitTestVisible="False" VerticalAlignment="Center" /> |
</StackPanel> |
</Grid> |
</ControlTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
Thanks (using 2009 Q3 SP2)
James.
I have added a <ControlTemplate.Triggers> section to your XAML in order to have the two texts hiding when there are items in the GroupPanel.
<
Style
TargetType
=
"telerik:GridViewGroupPanel"
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:GridViewGroupPanel"
>
<
Grid
Background
=
"Transparent"
>
<
Border
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
Opacity
=
"0.6"
/>
<
Border
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
/>
<
WrapPanel
Margin
=
"-2,0,0,0"
>
<
ItemsPresenter
x:Name
=
"itemsPresenter"
Margin
=
"0,20,3,0"
/>
</
WrapPanel
>
<
StackPanel
Orientation
=
"Vertical"
Margin
=
"10,10,0,0"
>
<
TextBlock
x:Name
=
"Text1"
Text
=
"Logged Events"
FontFamily
=
"Times New Roman"
FontSize
=
"20"
IsHitTestVisible
=
"False"
VerticalAlignment
=
"Center"
/>
<
TextBlock
x:Name
=
"Text2"
Text
=
"Drag a column header and drop it here to group by that column"
Opacity
=
"0.5"
FontFamily
=
"Arial"
FontSize
=
"10"
IsHitTestVisible
=
"False"
VerticalAlignment
=
"Center"
/>
</
StackPanel
>
</
Grid
>
<
ControlTemplate.Triggers
>
<!--Grouping HasGroups State-->
<
Trigger
Property
=
"HasItems"
Value
=
"True"
>
<
Setter
Property
=
"Visibility"
TargetName
=
"Text1"
Value
=
"Collapsed"
/>
<
Setter
Property
=
"Visibility"
TargetName
=
"Text2"
Value
=
"Collapsed"
/>
</
Trigger
>
</
ControlTemplate.Triggers
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
Kind regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.