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

header row font color

11 Answers 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Veena
Top achievements
Rank 1
Veena asked on 25 Jul 2019, 03:04 AM
Hi, I want to change font color of wpf radgridview header row in xaml with styles. please let me know the possible way.

11 Answers, 1 is accepted

Sort by
0
Dimitar Dinev
Telerik team
answered on 25 Jul 2019, 08:49 AM
Hi Veena,

The GridViewHeaderRow consist of GridViewHeaderCells and therefore, the best approach is to set the Foreground to them.

<!--If NoXaml is the preferred styling mechanism, add BasedOn="{StaticResource GridViewHeaderCellStyle}"-->
<
Style TargetType="telerik:GridViewHeaderCell">
     <Setter Property="Foreground" Value="Blue"/>
</Style>

Attached, you can find a sample project demonstrating this approach. Please, review it and let me know if you find it helpful.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Veena
Top achievements
Rank 1
answered on 25 Jul 2019, 08:52 AM

Hi, 

Thanks for the reply. I want to change the Header row mouse over/selection background color and I am not getting any properties for that.. please help.

0
Dimitar Dinev
Telerik team
answered on 26 Jul 2019, 09:57 AM
Hello Veena,

Тhere is a MouseOver visual state which controls the Opacity of a Border element and this is what is displayed once you hover over the GridViewHeaderCell. In order to override this background, you need to edit the control template of the GridViewHeaderCell.

You can avoid that by using the Fluent/Material/Crystal themes using mat:MaterialAssist.MouseOverBrush for the hover state and  mat:MaterialAssist.PressedBrush for the selected state.

Please, let me know if that answers your query.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Veena
Top achievements
Rank 1
answered on 26 Jul 2019, 10:02 AM

There is no option with exposed properties or styles without editing control template GridViewHeaderCell.?

Also I tried checking for control template in visual studio on right click of grid -> EditAdditionalTemplates.. I don't see GridViewHeaderCell option at all. 

Could you please give some example on this?

0
Dimitar Dinev
Telerik team
answered on 26 Jul 2019, 10:56 AM
Hi,

The behavior you want to achieve is possible by using one of the themes Material/Fluent/Crystal and the Material Assist helper ​class. This class exposes a set of attached properties which can be used to directly modify the appearance of a specific basic control without the need to alter its control template.

I modified the sample project to use the Material theme and the above described approach. As a result, the following style is the one needed for your scenario

<Style TargetType="telerik:GridViewHeaderCell">
    <Setter Property="mat:MaterialAssist.MouseOverBrush" Value="Red"/>
    <Setter Property="mat:MaterialAssist.PressedBrush" Value="Pink"/>
</Style>

where mat is the following namespace:

xmlns:mat="clr-namespace:Telerik.Windows.Controls.MaterialControls;assembly=Telerik.Windows.Controls"

Please, review the project and let me know if it delivered the desired result.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Veena
Top achievements
Rank 1
answered on 26 Jul 2019, 02:14 PM
Thanks for reply with sample project. May I know how to edit template for headercell in visual studio? as I mentioned earlier I am not seeing it in menu. my visual studio version is 2017.
0
Dimitar Dinev
Telerik team
answered on 26 Jul 2019, 03:56 PM
Hello,

You can edit the control template by copying the default styles for the theme and control that you are using. These styles can be found in the installation folder of Telerik UI for WPF. To edit the control template of the RadGridView's header cell, you need to go in the Themes.Implicit\WPF40\Material\Themes and locate the file Telerik.Windows.Controls.GridView. In your case, the following styles and templates are required - GridViewHeaderCellTemplate, ColumnHeaderGripperStyle and ​GridViewHeaderCell.

For more information visit on how to extract and modify the templates in Visual Studio, please have a look at the Editing Control Templates article.

For your convenience, I've modified the sample project using the above description. Please, review it and let me know if it helps.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Veena
Top achievements
Rank 1
answered on 29 Jul 2019, 08:54 AM

Hi, 

thanks for the reply. I don't want to change any themes now as I already have set some styles with default theme. I just want to change header row selection/mouse over color now. Please let me know exact path where can I find GridViewHeaderCellTemplate for default theme?

0
Veena
Top achievements
Rank 1
answered on 29 Jul 2019, 09:07 AM
Also I am not able to extract HeaderRowCellTemplate using visual studio designer. I can see other menus but not HeaderRowCellTemplate. I tried even modifying the GridView template itself. But it doesn't have this HeaderRowCellTemplate.
0
Veena
Top achievements
Rank 1
answered on 29 Jul 2019, 09:29 AM
Also please give me sample template for removing the selection/mouse over color on header row.
0
Dimitar Dinev
Telerik team
answered on 29 Jul 2019, 11:55 AM
Hello,

The default theme which comes out of the box when no theme is set is OfficeBlack. The path to the control template is {​installation folder}\Themes.Implicit\WPF40\OfficeBlack\Themes\Telerik.Windows.Controls.GridView.

For your convenience I've updated the sample project by extracting the control template for GridViewHeaderCellTemplate and added all the necessary resources. You can make the changes you aim for in the GridViewHeaderCell_Over and ​GridViewHeaderCell_Selected elements.

I hope this helps.

Regards,
Dimitar Dinev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Veena
Top achievements
Rank 1
Answers by
Dimitar Dinev
Telerik team
Veena
Top achievements
Rank 1
Share this question
or