Data Grid alternativebackground property causing problems with datagrid row style

Jun 1, 2009 at 6:03 AM
Edited Jun 1, 2009 at 6:14 AM


     By Using he "AlternatingRowBackground" property I created the grid with row in alternateColor . But when I use a style for DataGridRow to change its back ground color on mouseOver there is no change in the back ground color created with "AlternatingRowBackground" property.But the rest rows are changing its back ground. Why this behaviour and please tell me what is the solution for this.

Below is the code .

//name space used

xmlns:dg ="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"


//Creating the grid with Alternate Color



Grid x:Name="LayoutRoot">

 <Canvas x:Name="ParameterArea" d:LayoutOverrides="VerticalAlignment">


x:Name ="PlaceControlControl"

Width="510" Height="400"

AlternationCount ="2"


Style="{DynamicResource DataGridNewStyle}"





///........ some code for filling the data grid





///Style for grid

<Style x:Key="DataGridNewStyle" TargetType="{x:Type dg:DataGrid}">

....some code for setting style for dataGrid

Setter Property="RowStyle" Value="{StaticResource dgRowStyle}"/>

....some code for setting style for dataGrid




///Now the style for a row



<Style x:Key="dgRowStyle" TargetType="dg:DataGridRow">

<Setter Property="SnapsToDevicePixels" Value="True" />

<Setter Property="Background" Value="LightGray"/>






<Condition Property="IsMouseOver" Value="true"/>


<Condition Property="IsSelected" Value="True"/>


<Setter Property="BorderBrush" Value="#7F26AAF0" />



<Trigger Property="IsMouseOver" Value="true">

<Setter Property="Background" Value="#7F808080"/>


<Trigger Property="IsSelected" Value="true">

<Setter Property="Background" Value="#7F26AAF0"/>


<Trigger Property="IsKeyboardFocusWithin" Value="True">

<Setter Property="BorderBrush" Value="#7F26AAF0" />





By using this code i could change the back ground of the row on mouse over except the row with "AlternatingRowBackground"


Thanks and regards

Jithesh Kumar