WPF: Animating TranslateTransform from code

前端 未结 4 870
梦如初夏
梦如初夏 2021-02-04 02:17

I have a WPF canvas on which I\'m dynamically creating objects from code. These objects are being transformed by setting the RenderTransform property, and an animation needs to

4条回答
  •  温柔的废话
    2021-02-04 03:00

    I have a Solution using XAML / C# Combo. In your XAML file define:

    
        
    
    

    This will give you the ability to do the following in the C# code:

            Storyboard.SetTargetName(mFlyInDA, "panelTrans");
            Storyboard.SetTargetProperty(mFlyInDA, new PropertyPath("Y"));
    

    The rest is business as usual. Create a DoubleAnimation, set its properties, add it as a child to your Storyboard, call the Begin function on the story board.

提交回复
热议问题