Hi Team,
I am using VS 2019 and Infragistics 20.2.16 version.
I am facing issue on changing style of XamDataGrid for below parts.
1) How to change the style header row select and hover background color. Suggest how I remove the glow background color for header row.
code that I used:
<Style x:Key="labelPresenter" TargetType="{x:Type data:LabelPresenter}"> <Setter Property="Background" Value="#d0d0d0" /> <Setter Property="FontFamily" Value="Poppins Medium" /> <Setter Property="FontSize" Value="10" /> <Setter Property="Foreground" Value="#595959" /> <Setter Property="BorderBrush" Value="#FFFFFF" /> <Setter Property="Height" Value="30" /> <Setter Property="LabelHighlight" Value="Transparent"/> </Style>
2) How to remove the glow background color for selected row.
<Style x:Key="dataRecordCellArea" TargetType="{x:Type data:DataRecordCellArea}"> <Setter Property="CornerRadius" Value="0" /> <Setter Property="BackgroundAlternate" Value="{StaticResource CellItemAltNormalBackgroundBrush}" /> <Setter Property="BackgroundSelected" Value="{StaticResource CellRowHoverBackgroundBrush}" /> <Setter Property="BackgroundHover" Value="{StaticResource CellRowHoverBackgroundBrush}" /> </Style>
3) How to remove one horizontal line in Header row column separator.
4) How to show arrow of sorting in Header row.
For your reference I attach the Image.
Thank You,
Dinesh
Hello Dinesh,
I have created a small sample application that demonstrates my suggestions of how your questions could be resolved.
For your first question, I have copied the LabelPresenter and the LabelContent styles from the DataPresenter_Aero file, which is inside the DefaultStyles directory, that can be found under:
C:\Program Files (x86)\Infragistics\[Your version]\WPF\DefaultStyles\DataPresenter
The styles are placed inside the Application.Resources and then, in order to change the highlight color you the Background and BorderBrush colors should be set to Transparent. They can be found in the Hightlight section starting from line 101 inside App.xaml.
Similarly, the SortIndicatiors could be shown in the LabelPresenter style inside the Application.Resources. To show them, the Visibility property of the SortIndicator needs to be changed to “Visible”, this could be found on line 156. In the sample application I am sending to make the SortIndicators more visible I have added background color as well and set its value to “Black”.
To remove the highlight color of the selected row, a style targeting the DataRecordCellArea needs to be included. In it the BackgroundSelected and BackgroundActive needs to be set to “Transparent”.
As for the question about the whitespace between the field headers, could you clarify more about it? For example are you using some settings or a theme that could cause it?
Please test the sample on your side and let me know if you have any questions.
Regards, Ivan Kitanov
LabelPresenterChangesHighlightColorAndSortIndicators.zip
Thank Ivan for your reply.
But it seem very lengthy solution. Is there any simple way to get rid of this glow background color for full XamDataGrid.
The reason that I suggested using and overriding the Default Styles for the needs of your application is that the element that is controlling the color of the field headers while sorted is a border called “highlihg_2”. This border cannot be accessed outside of the Default Styles, since there is no property for it, as opposed to the “highlight” border which is responsible for the highlight when the user hovers a field header, that corresponds to the LabelHighlight.
If you only need the highlight color to be transparent, when the user hovers the field header you can use the following style:
<Style TargetType="{x:Type ig:LabelPresenter}"> <Setter Property="Background" Value="Transparent"/> <Setter Property="LabelHighlight" Value="Transparent"/> <Style>
If you need the highlight color when hovering and when sorting the field, you would need to use the Default Styles and would need to do the corresponding changes there. As for your question about the length of the Default Styles, it is very important keeping everything and not deleting code from it, since there may be some functionalities that would disappear or stop working correctly if you do that. When dealing with Default Styles, the best approach is to copy the whole style and then to add/edit your needed changes.
Hi Ivan,
Thanks for your reply. I understand to re-template the control.
I’m glad that you found my suggestion helpful and managed to resolve your issue.
Thank you for using Infragistics!