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>

我想使用这个故事板更改上边距,所以我应用了 KeyFrame 动画,但它没有使用 EasingFunction,因此不平滑,我将如何应用 Easing Function 来使动画平滑!

4

1 回答 1

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 中动画不能平滑,因为您必须使用仅支持离散插值方法ObjectAnimationUsingKeyFrames的forThickness动画。也不支持。EasingFunctions

于 2012-05-20T21:35:40.200 回答