2012-05-18 53 views
0
<Storyboard x:Name="stTOPAni"> 
     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="grdOverlay"> 
      <DiscreteObjectKeyFrame KeyTime="0"> 
       <DiscreteObjectKeyFrame.Value> 
        <Thickness>0</Thickness> 
       </DiscreteObjectKeyFrame.Value> 
      </DiscreteObjectKeyFrame> 
      <DiscreteObjectKeyFrame x:Name="key1" KeyTime="0:0:0.5"> 
       <DiscreteObjectKeyFrame.Value> 
        <Thickness>0,-500,0,0</Thickness> 
       </DiscreteObjectKeyFrame.Value> 

      </DiscreteObjectKeyFrame> 
      <DiscreteObjectKeyFrame KeyTime="0:0:1"> 
       <DiscreteObjectKeyFrame.Value> 
        <Thickness>0,-800,0,0</Thickness> 
       </DiscreteObjectKeyFrame.Value> 
      </DiscreteObjectKeyFrame> 
     </ObjectAnimationUsingKeyFrames> 

    </Storyboard> 

我想用這個故事板來改變上邊距,所以我applice關鍵幀動畫,但它不使用的easingFunction,因此不順利,我如何將適用緩動功能,使動畫流暢!適用於Windows Phone的緩動函數DiscreteObjectKeyFrame動畫

回答

0

在WPF中,你會簡單地使用... ThicknessKeyFrames之一。

<Storyboard x:Name="stTOPAni" Storyboard.TargetProperty="Margin"> 
    <ThicknessAnimationUsingKeyFrames> 
     <DiscreteThicknessKeyFrame KeyTime="0"> 
      <DiscreteThicknessKeyFrame.Value> 
       <Thickness>0</Thickness> 
      </DiscreteThicknessKeyFrame.Value> 
     </DiscreteThicknessKeyFrame> 
     <EasingThicknessKeyFrame KeyTime="0:0:1"> 
      <EasingThicknessKeyFrame.EasingFunction> 
       <CubicEase EasingMode="EaseInOut"/> 
      </EasingThicknessKeyFrame.EasingFunction> 
      <EasingThicknessKeyFrame.Value> 
       <Thickness>0,-800,0,0</Thickness> 
      </EasingThicknessKeyFrame.Value> 
     </EasingThicknessKeyFrame> 
    </ThicknessAnimationUsingKeyFrames> 
</Storyboard> 

但不幸的是在Silverlight動畫無法順利,因爲你必須使用Thickness動畫其中only supports discrete interpolation methodObjectAnimationUsingKeyFramesEasingFunctions也不受支持。