Skip to content

Instantly share code, notes, and snippets.

@iamanas20
Created November 12, 2018 11:22
Show Gist options
  • Save iamanas20/739f94c60846d6ce1ce60e85376ad36c to your computer and use it in GitHub Desktop.
Save iamanas20/739f94c60846d6ce1ce60e85376ad36c to your computer and use it in GitHub Desktop.
<Style TargetType="DataGrid">
<!-- Make the border and grid lines a little less imposing -->
<Setter Property="FontFamily" Value="Google Sans" ></Setter>
<Setter Property="BorderBrush" Value="#DDDDDD" />
<Setter Property="HorizontalGridLinesBrush" Value="#DDDDDD" />
<Setter Property="VerticalGridLinesBrush" Value="#DDDDDD" />
<Setter Property="RowHeight" Value="25"></Setter>
<Setter Property="RowStyle">
<Setter.Value>
<Style TargetType="DataGridRow">
<Style.Triggers>
<!-- Highlight a grid row as the mouse passes over -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="LightCyan" />
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
<Setter Property="CellStyle">
<Setter.Value>
<Style TargetType="DataGridCell">
<Style.Triggers>
<!-- Highlight selected rows -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#ff66aaff" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="#ff6691ff" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
<!-- Add some padding around the contents of a cell -->
<Setter Property="Padding" Value="4,3,4,3" />
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<Border Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style TargetType="Control">
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="ColumnHeaderStyle" Value="{DynamicResource HeaderStyle}"></Setter>
</Style>
<Style x:Key="HeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Height" Value="30"></Setter>
<Setter Property="Background" Value="#60c6cf"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontWeight" Value="DemiBold" ></Setter>
<Setter Property="FontSize" Value="14" ></Setter>
<Setter Property="Padding" Value="10,0,10,0" ></Setter>
</Style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment