2011-02-03 18 views
3

WPFこれはDataGridRowとうまく動作しますが、私はこれらを追加するときに、マウスオーバーのスタイルは...DataGridが、代替行の色で作業していないホバー

<Trigger Property="ItemsControl.AlternationIndex" Value="0"> 
    <Setter Property="Background" Value="{StaticResource LightRowBrush0}" /> 
</Trigger> 
<Trigger Property="ItemsControl.AlternationIndex" Value="1"> 
    <Setter Property="Background" Value="{StaticResource LightRowBrush1}" /> 
</Trigger> 
を動作しません -

答えて

7

スタイルの順序が重要です。

他のトリガーが適用される前に交互トリガを適用します。

<Style.Triggers> 
     <Trigger Property="ItemsControl.AlternationIndex" Value="0"> 
      <Setter Property="Background" Value="{StaticResource LightRowBrush0}" /> 
     </Trigger> 
     <Trigger Property="ItemsControl.AlternationIndex" Value="1"> 
      <Setter Property="Background" Value="{StaticResource LightRowBrush1}" /> 
     </Trigger> 
     <Trigger Property="IsMouseOver" Value="true"> 
      <Setter Property="Background" Value="{StaticResource RolloverBrush}" /> 
      <Setter Property="Foreground" Value="#000" /> 
     </Trigger> 
     <Trigger Property="IsSelected" Value="true"> 
      <Setter Property="Background" Value="{StaticResource SelectedBrush}" /> 
      <Setter Property="Foreground" Value="#000" /> 
     </Trigger> 
    </Style.Triggers> 
+0

私は.. –

+0

まだ代替行didntの仕事私のために私がチェックしている必要がありますごめんなさい:( –

+2

しかし、これは働いていた、 '<スタイルのTargetType = "データグリッド" BASEDON =" {StaticResource {X:タイプのDataGrid} } "> ' –

関連する問題