Skip to content

Instantly share code, notes, and snippets.

@yavor87
Last active January 20, 2019 12:37
Show Gist options
  • Save yavor87/34fc695ab059b4f34c49651257046511 to your computer and use it in GitHub Desktop.
Save yavor87/34fc695ab059b4f34c49651257046511 to your computer and use it in GitHub Desktop.
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type telerik:GridViewCell}" BasedOn="{StaticResource GridViewCellStyle}">
<Setter Property="Background" Value="#ffcc00"/>
</Style>
<Style TargetType="{x:Type telerik:GridViewHeaderCell}" BasedOn="{StaticResource GridViewHeaderCellStyle}">
<Setter Property="Background" Value="LimeGreen"/>
<Setter Property="Foreground" Value="Cyan"/>
</Style>
</Grid.Resources>
<telerik:RadGridView ItemsSource="{x:Static local:SampleData.Employees}" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding FullName}" />
<telerik:GridViewDataColumn Header="Department" DataMemberBinding="{Binding Department}" />
<telerik:GridViewDataColumn Header="Salary" DataMemberBinding="{Binding Salary}" DataFormatString="{}{0:C0}">
<telerik:GridViewDataColumn.CellStyle>
<Style TargetType="{x:Type telerik:GridViewCell}" BasedOn="{StaticResource GridViewCellStyle}">
<Setter Property="Background" Value="Green"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</telerik:GridViewDataColumn.CellStyle>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
<telerik:RadGridView ShowGroupPanel="False" GridLinesVisibility="Vertical"
ShowColumnHeaders="False" ColumnBackground="Bisque"
RowIndicatorVisibility="Collapsed"/>
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type telerik:RadGridView}" BasedOn="{StaticResource RadGridViewStyle}">
<Setter Property="ShowGroupPanel" Value="False" />
<Setter Property="GridLinesVisibility" Value="Vertical" />
<Setter Property="ShowColumnHeaders" Value="False" />
<Setter Property="ColumnBackground" Value="Bisque" />
<Setter Property="RowIndicatorVisibility" Value="Collapsed" />
</Style>
</Grid.Resources>
<telerik:RadGridView />
</Grid>
<Grid>
<Grid.Resources>
<Style x:Key="MyGridRowStyle" TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource GridViewRowStyle}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource MyGridRowStyle}">
<Setter Property="Background" Value="SeaGreen"/>
</Style>
<Style TargetType="{x:Type telerik:GridViewHeaderRow}" BasedOn="{StaticResource GridViewHeaderRowStyle}">
<Setter Property="Background" Value="MidnightBlue"/>
</Style>
</Grid.Resources>
<telerik:RadGridView ItemsSource="{x:Static local:SampleData.Employees}" AlternationCount="2">
<telerik:RadGridView.AlternateRowStyle>
<Style TargetType="{x:Type telerik:GridViewRow}" BasedOn="{StaticResource MyGridRowStyle}">
<Setter Property="Background" Value="LightGoldenrodYellow" />
</Style>
</telerik:RadGridView.AlternateRowStyle>
</telerik:RadGridView>
</Grid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment