2012-04-22 11 views
0

私はTabItemの背景/グラデーションをアニメーション化しようとしています。ただし、エラーが発生しています。私のWPF TabItemアニメーションで何が問題になっていますか?

Additional information: Cannot resolve all property references in the property path 'Background.GradientStops[2].Color'. Verify that applicable objects support the properties.

タブアイテムの上にマウスを重ねるとエラーが発生します。私はStoryboard.TargetPropertyが間違っていると思う

<Style TargetType="{x:Type TabItem}"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type TabItem}"> 
       <Grid> 
        <Border Name="Border" BorderBrush="#666" BorderThickness="1,1,1,0" CornerRadius="8,8,0,0" Margin="-2,0,3,-1"> 
         <!-- Some irrelevant code here --> 
        </Border> 

        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal"/> 
          <VisualState x:Name="MouseOver"> 
           <Storyboard> 
            <ColorAnimation Duration="0:0:0.3" To="#EBEBEB" Storyboard.TargetProperty="Background.GradientStops[1].Color" Storyboard.TargetName="Border"/> 
            <ColorAnimation Duration="0:0:0.3" To="#CDCDCD" Storyboard.TargetProperty="Background.GradientStops[2].Color" Storyboard.TargetName="Border"/> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
       </Grid> 

       <ControlTemplate.Triggers> 
        <Trigger Property="IsSelected" Value="True"> 
         <Setter TargetName="Border" Property="Background"> 
          <Setter.Value> 
           <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> 
            <GradientStop Color="#fff" Offset="0.35"></GradientStop> 
            <GradientStop Color="#e9e9e9" Offset="0.75"></GradientStop> 
           </LinearGradientBrush> 
          </Setter.Value> 
         </Setter> 
        </Trigger> 

        <Trigger Property="IsSelected" Value="False"> 
         <Setter TargetName="Border" Property="Background"> 
          <Setter.Value> 
           <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> 
            <GradientStop Offset="0.35"> 
             <GradientStop.Color> 
              <Color A="127" R="255" G="255" B="255" /> 
             </GradientStop.Color> 
            </GradientStop> 

            <GradientStop Offset="0.75"> 
             <GradientStop.Color> 
              <Color A="127" R="233" G="233" B="233" /> 
             </GradientStop.Color> 
            </GradientStop> 
           </LinearGradientBrush> 
          </Setter.Value> 
         </Setter> 
        </Trigger> 
       </ControlTemplate.Triggers> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

はここでXAMLです。それは何でしょうか?

答えて

1

ゼロベースのインデックスではいけませんか?

<Storyboard> 
    <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[0].Color" .../> 
    <ColorAnimation Storyboard.TargetProperty="Background.GradientStops[1].Color" .../> 
</Storyboard> 
+0

どのように私はそれを見つけませんでした! – Tower

関連する問題