如何使用C#而不是XAML在运行时动态更改运动路径?

时间:2019-02-10 17:14:44

标签: wpf xaml storyboard motion

我得到的故事板具有通过将椭圆转换为运动路径而构建的运动路径,我想将旧点更改为调整大小的椭圆的新点

<Storyboard x:Name="orbit_plan" x:Key="orbit_planet">
         <DoubleAnimationUsingPath Duration="0:0:4" Source="X" 
 Storyboard.TargetProperty="(UIElement.RenderTransform). 
 (TransformGroup.Children)[3].(TranslateTransform.X)" 
 Storyboard.TargetName="rectangle" RepeatBehavior="Forever">
            <DoubleAnimationUsingPath.PathGeometry>
                <PathGeometry x:Name="fig" Figures="M498.5,-45.25 
 C498.5,13.568326 405.15137,61.25 290,61.25 C174.84863,61.25 81.5,13.568326 
 81.5,-45.25 C81.5,-104.06833 174.84863,-151.75 290,-151.75 
 C405.15137,-151.75 498.5,-104.06833 498.5,-45.25 z"/>
            </DoubleAnimationUsingPath.PathGeometry>
        </DoubleAnimationUsingPath>
        <DoubleAnimationUsingPath Duration="0:0:4" Source="Y" 
 Storyboard.TargetProperty="(UIElement.RenderTransform). 
 (TransformGroup.Children)[3].(TranslateTransform.Y)" 
 Storyboard.TargetName="rectangle" RepeatBehavior="Forever">
            <DoubleAnimationUsingPath.PathGeometry>
                <PathGeometry Figures="M498.5,-45.25 C498.5,13.568326 
405.15137,61.25 290,61.25 C174.84863,61.25 81.5,13.568326 81.5,-45.25 
C81.5,-104.06833 174.84863,-151.75 290,-151.75 C405.15137,-151.75 
498.5,-104.06833 498.5,-45.25 z"/>
             </DoubleAnimationUsingPath.PathGeometry>
         </DoubleAnimationUsingPath>   

我想将Storyboard连接到新的椭圆,以便更改路径以适应新的椭圆

0 个答案:

没有答案