Hello,
I've some grids in a SL 5 application, I've defined a style for the first row I was wondering if it's possible to apply it to all the RadGrid I've instead of setting it as
Is this possible?
How?
Thanks in advance
Paolo
I've some grids in a SL 5 application, I've defined a style for the first row I was wondering if it's possible to apply it to all the RadGrid I've instead of setting it as
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding DESCRIZIONE}"
Header
=
"{Binding Path=Resource1.DESCRIZIONE, Source={StaticResource LocalizedStrings }}"
HeaderCellStyle
=
"{StaticResource GridViewHeaderCellStyleFirst}"
UniqueName
=
"DESCRIZIONE"
/>
Is this possible?
How?
Thanks in advance
Paolo
5 Answers, 1 is accepted
0
Hi Paolo,
The first row is the header row. This row contains header cells. These row and the cells have different styles when compared to the other rows and cells so you would have to modify them if you want to change the style.
There are two possible approaches to your issue.
In order to apply a style to all elements of the same type in several gridviews you have to omit the x:Key property. This will cause the style to be applied to all items matching the TargetType. This is known as an implicit style. More information on implicit styles can be found here: link.
You can see following the snippet for an example of an implicit style:
Regards,
Hristo
Telerik
The first row is the header row. This row contains header cells. These row and the cells have different styles when compared to the other rows and cells so you would have to modify them if you want to change the style.
There are two possible approaches to your issue.
- To create an empty style and set it up on your own.
- To copy the default style of the control and modify it.
In order to apply a style to all elements of the same type in several gridviews you have to omit the x:Key property. This will cause the style to be applied to all items matching the TargetType. This is known as an implicit style. More information on implicit styles can be found here: link.
You can see following the snippet for an example of an implicit style:
<
Style
TargetType
=
"telerik:GridViewHeaderCell"
>
<
Setter
Property
=
"Background"
Value
=
"Green"
/>
</
Style
>
Regards,
Hristo
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
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 >>
0

Michele
Top achievements
Rank 2
answered on 13 Jan 2014, 09:05 AM
Hello,
I was menaning the first column.......I need to have the fist column of a grid to be styled in a particular way....... I don't want to put a Cell style on each page...
Thanks
0
Hello Paolo,
You can not target the first column directly, because the columns are not visual elements. Instead you can create a style targeting GridViewCell or GridViewHeaderCell depending on what you want to style. After that you would have to assign a value to the x:key property. Following this you would have to use CellStyle (HeaderCellStyle) for the column you want to style and call the static resource specified by the key. The style is located inside UserControl.Resources
You can see the following snippet for example:
More information on styling the column headers can be found in our online documentation on the following link: link
Regards,
Hristo
Telerik
You can not target the first column directly, because the columns are not visual elements. Instead you can create a style targeting GridViewCell or GridViewHeaderCell depending on what you want to style. After that you would have to assign a value to the x:key property. Following this you would have to use CellStyle (HeaderCellStyle) for the column you want to style and call the static resource specified by the key. The style is located inside UserControl.Resources
You can see the following snippet for example:
<
UserControl.Resources
>
<
Style
TargetType
=
"telerik:GridViewCell"
x:Key
=
"FirstColumn"
>
<
Setter
Property
=
"Background"
Value
=
"Green"
/>
</
Style
>
</
UserControl.Resources
>
<!-- more xaml code here -->
<
telerik:RadGridView
Name
=
"playersGrid"
ItemsSource
=
"{Binding Players}"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Name}"
CellStyle
=
"{StaticResource FirstColumn}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Number}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Position}"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Country}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
More information on styling the column headers can be found in our online documentation on the following link: link
Regards,
Hristo
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
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 >>
0

T
Top achievements
Rank 1
answered on 22 Aug 2014, 09:45 AM
I think the first data column should in fact use
HeaderCellStyle="{StaticResource FirstColumn}"
No?
HeaderCellStyle="{StaticResource FirstColumn}"
No?
0
Hi,
You should apply HeaderCellStyle if you would like to style the GridViewHeaderCells. On the other hand, when you need to style the GridViewCells, then you should apply a CellStyle as my colleague suggested.
You can also refer to the RadGridView Styles and Templates section in our documentation.
Regards,
Didie
Telerik
You should apply HeaderCellStyle if you would like to style the GridViewHeaderCells. On the other hand, when you need to style the GridViewCells, then you should apply a CellStyle as my colleague suggested.
You can also refer to the RadGridView Styles and Templates section in our documentation.
Regards,
Didie
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.