更改telerik的默认颜色:RadGridView从黑色到蓝色

时间:2013-07-01 23:51:58

标签: c# wpf telerik

我有一个使用telerik的RadGridView,默认颜色是黑色。我想知道如何改变这种颜色。

 <telerik:RadGridView Name="dgData1"
ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Visible"  VerticalAlignment="Bottom"
                                 AutoGenerateColumns="False" Grid.Column="0"
                                 ShowGroupPanel="False" 
                                 IsFilteringAllowed="False" 
                                 CanUserReorderColumns="False"
                                 RowIndicatorVisibility ="Collapsed"
                                 IsReadOnly="True"
                                 EnableRowVirtualization="False"
                                 EnableColumnVirtualization="False"
                                 SelectionMode="Single"
                                 Sorting="dgData_Sorting">
            </telerik:RadGridView>

2 个答案:

答案 0 :(得分:2)

试试这段代码:

<telerik:RadGridView ItemsSource="{Binding}" Background="Red" Foreground="White" AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="24,36,0,0" Name="radGridView1" VerticalAlignment="Top">
        <telerik:RadGridView.RowStyle>
            <Style TargetType="{x:Type telerik:GridViewRow}">
                <Setter Property="Background" Value="Red"/>
                <Setter Property="Foreground" Value="White"/>
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="Background" Value="DarkOrange"/>
                        <Setter Property="Foreground" Value="black"/>
                    </Trigger>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="LightYellow"/>
                        <Setter Property="Foreground" Value="black"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </telerik:RadGridView.RowStyle>
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="EmployeeID" DataMemberBinding="{Binding EmployeeID}"/>
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

希望这对你有所帮助。

答案 1 :(得分:0)

您需要做的就是将“telerik:StyleManager.Theme =”Summer“”添加到数据网格视图中。

<telerik:RadGridView Name="someName" telerik:StyleManager.Theme="Summer"
                                 AutoGenerateColumns="False" Grid.Column="0"
                                 ShowGroupPanel="False" 
                                 IsFilteringAllowed="False" 
                                 CanUserReorderColumns="False"
                                 RowIndicatorVisibility ="Collapsed"
                                 IsReadOnly="True"
                                 EnableRowVirtualization="False"
                                 EnableColumnVirtualization="False"
                                 SelectionMode="Single"
  </telerik:RadGridView>