简体   繁体   English

如何更改鼠标 hover 上的 telerik:RadGridView 行背景颜色

[英]How to change telerik:RadGridView row background color on mouse hover

I'm quite new to telerik controls.我对 telerik 控件很陌生。 I'm working with a telerik:RadGridView and by default the background of the row was changed into light grayish color when the mouse cursor was hovered above that row.我正在使用 telerik:RadGridView 并且默认情况下,当鼠标 cursor 悬停在该行上方时,该行的背景变为浅灰色。 This makes the texts from the row hard to read.这使得该行中的文本难以阅读。 So, I was wondering is there a way to change the row background to blue instead of the light grayish color when the row's being hovered.所以,我想知道当行悬停时,有没有办法将行背景更改为蓝色而不是浅灰色。 Also, my telerik version is 2016. The following is the grid I'm working with.另外,我的 telerik 版本是 2016。以下是我正在使用的网格。

<telerik:RadGridView x:Name="gridReport" ItemsSource="{Binding Tab.ListGraphReport}" 
                                                         ItemTemplate="{StaticResource ListBoxDataTemplate}"
                                                         GroupPanelBackground="Transparent" 
                                                         GroupPanelForeground="White"  
                                                         RowIndicatorVisibility="Collapsed" 
                                                         ColumnWidth="*" 
                                                         Background="Transparent" 
                                                         Foreground="White"
                                                         AutoGenerateColumns="False"
                                                         ShowGroupPanel="False">
                                        <telerik:RadGridView.Columns>
                                            <telerik:GridViewDataColumn Header="Indicator" IsFilterable="False">
                                                <telerik:GridViewDataColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <Grid>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="*" />
                                                                <ColumnDefinition Width="6*"/>
                                                            </Grid.ColumnDefinitions>
                                                            <Rectangle Height="10" Width="10" Fill="{Binding ColorName, Converter={StaticResource NVarToBrushConverter}}" Grid.Column="0" />
                                                            <TextBlock Text="{Binding Graph}" Grid.Column="1"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </telerik:GridViewDataColumn.CellTemplate>
                                            </telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn Header="Min" DataMemberBinding="{Binding Min}" DataFormatString="{}{0:N2}" IsFilterable="False" >
                                            </telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn Header="Max" DataMemberBinding="{Binding Max}" DataFormatString="{}{0:N2}" IsFilterable="False">
                                            </telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn Header="AVG" DataMemberBinding="{Binding Avg}" DataFormatString="{}{0:N2}" IsFilterable="False">
                                            </telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn Header="Unit" DataMemberBinding="{Binding Unit}" DataFormatString="{}{0:N2}" IsFilterable="False">
                                            </telerik:GridViewDataColumn>
                                        </telerik:RadGridView.Columns>
                                    </telerik:RadGridView>

You will need to copy the default ControlTemplate for the GridViewRow from Themes.Implicit\WPF40\ExpressionDark\Themes\Telerik.Windows.Controls.GridView.xaml and change the Background property of the Background_Over element, or the Color of the ItemBackground_Over brush: You will need to copy the default ControlTemplate for the GridViewRow from Themes.Implicit\WPF40\ExpressionDark\Themes\Telerik.Windows.Controls.GridView.xaml and change the Background property of the Background_Over element, or the Color of the ItemBackground_Over brush:

<SolidColorBrush x:Key="ItemBackground_Over" Color="#FF565656"/>

To change the mouse over background of the RadGridView rows, set the MouseOverBackground property of the GridViewRow controls.若要将鼠标悬停在RadGridView行的背景上,请设置GridViewRow控件的MouseOverBackground属性。

<telerik:RadGridView.RowStyle>
    <Style TargetType="telerik:GridViewRow">
        <Setter Property="MouseOverBackground" Value="Red" />
    </Style>
</telerik:RadGridView.RowStyle>

Read more about this here: https://docs.telerik.com/devtools/wpf/controls/radgridview/rows/selected-row-background在此处阅读有关此内容的更多信息: https://docs.telerik.com/devtools/wpf/controls/radgridview/rows/selected-row-background

Note that, if you use NoXaml dlls you will need to base the row style to the default GridViewRowStyle .请注意,如果您使用NoXaml dll,您需要将行样式设置为默认的GridViewRowStyle

<telerik:RadGridView.RowStyle>
    <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
        <Setter Property="MouseOverBackground" Value="Red" />
    </Style>
</telerik:RadGridView.RowStyle>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM