简体   繁体   English

WPF代码隐藏动画c#

[英]WPF codebehind animation c#

Can anyone help me how to create an animation thru codebehind using an that will take a motion using a defined controls?任何人都可以帮助我如何通过使用定义的控件进行动作的代码隐藏来创建动画吗?

please dont closed this i really need help on this....请不要关闭这个我真的需要帮助....

<Image x:Name="imgMan" Source="/wpfUsrControlTower1;component/DependentResources/man.png" Stretch="Fill" Height="26.4">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
</Image>

<Path x:Name="k3_r2" Visibility="Hidden" Fill="Transparent" StrokeThickness="3" StrokeDashArray="2 0 0 2" Stretch="Fill" Stroke="Blue" Data="M570,190 L570,160 495,160 495,125 165,125 165,175" Height="65" Canvas.Left="165" Canvas.Top="125" Width="405"/>

With a MatrixTransform as the Image's RenderTransform使用 MatrixTransform 作为图像的 RenderTransform

<Canvas>
    <Path x:Name="k3_r2"
          StrokeThickness="3" StrokeDashArray="4 4" Stroke="Blue"
          Data="M570,190 L570,160 495,160 495,125 165,125 165,175"/>

    <Image x:Name="imgMan"
           Source="/wpfUsrControlTower1;component/DependentResources/man.png"
           Stretch="Fill" Height="30"
           Canvas.Left="-15" Canvas.Top="-15">
        <Image.RenderTransform>
            <MatrixTransform/>
        </Image.RenderTransform>
    </Image>
</Canvas>

you may use something like this:你可以使用这样的东西:

var animation = new MatrixAnimationUsingPath
{
    PathGeometry = PathGeometry.CreateFromGeometry(k3_r2.Data),
    Duration = TimeSpan.FromSeconds(5)
};

imgMan.RenderTransform.BeginAnimation(MatrixTransform.MatrixProperty, animation);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM