【问题标题】:Draw line using storyboard animation windows phone使用情节提要动画windows phone画线
【发布时间】:2015-03-19 14:44:15
【问题描述】:

我在 windows phone 运行时应用中有一行。

<Line x:Name="Line1" Height="178" Width="166" Stretch="Fill" StrokeDashArray="4,4" StrokeThickness="1" Stroke="Black" X1="100" Y1="150" X2="105" Y2="108" RenderTransformOrigin="0.5,0.5">

我想为这条线设置动画,使其长度从(X1,Y1)开始增加并一直增加到(X2,Y2) em>,具有画线效果

PS:我使用的是 Line 而不是 Path。

这是我所做的:

<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Line1" Storyboard.TargetProperty="X2" EnableDependentAnimation="True">
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="101" />
                            <EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="102" />
                            <EasingDoubleKeyFrame KeyTime="0:0:4" Value="103" />
                            <EasingDoubleKeyFrame KeyTime="0:0:5" Value="104" />
                            <EasingDoubleKeyFrame KeyTime="0:0:8" Value="105" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Line1" Storyboard.TargetProperty="Y2" EnableDependentAnimation="True">
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="120" />
                            <EasingDoubleKeyFrame KeyTime="0:0:4" Value="110" />
                            <EasingDoubleKeyFrame KeyTime="0:1:0" Value="108" />
                        </DoubleAnimationUsingKeyFrames>

也尝试过ScaleTransform,但没有达到我的预期。

对此的任何解决方案将不胜感激。

【问题讨论】:

    标签: windows-runtime windows-phone storyboard windows-phone-8.1 scaletransform


    【解决方案1】:

    我会在Line 上放置一个RectangleGeometry Clip 区域,将Transform 应用于几何体,将变换上的旋转设置为对应于线方向,几何体上的Rect 为对应于线长/粗细,并将Transform 的比例从 0 设置为 1。

    应该会为您提供一条在绘制时不会移动的线条和流畅的动画。

    【讨论】:

    • 谢谢你这么好的解释!!工作得很好! +一个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-23
    • 1970-01-01
    • 2011-01-12
    • 2015-02-14
    • 1970-01-01
    相关资源
    最近更新 更多