2011-02-03 43 views
3

這個工程只是DataGridRow很好..Datagrid的懸停不與備用行顏色的工作 - WPF

<Trigger Property="IsMouseOver" Value="true"> 
     <Setter Property="Background" Value="{StaticResource RolloverBrush}" /> 
     <Setter Property="Foreground" Value="#000" /> 
    </Trigger> 

但是當我添加這些時,鼠標懸停樣式不工作..

<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

我很抱歉,我應該檢查.. – 2011-02-03 14:48:45