I need to animate a RectangleGeometry in C#, but I don't know what is the path to use for the ProperyPath.
rectAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("What-is-the-path?"));
XAML:
<Image x:Name="Item" Source="{StaticResource ItemDragComplete00bw}" Stretch="None">
<Image.Clip>
<RectangleGeometry Rect="0, 0, 684, 250" RadiusX="10" RadiusY="10">
<RectangleGeometry.Transform>
<TransformGroup>
<ScaleTransform CenterX="342" CenterY="0" ScaleX="0.366" ScaleY="1.0"/>
</TransformGroup>
</RectangleGeometry.Transform>
</RectangleGeometry>
</Image.Clip>
</Image>
C#
RectAnimation rectAnimation = new RectAnimation();
rectAnimation.Duration = TimeSpan.FromMilliseconds(toMills - fromMills);
rectAnimation.FillBehavior = FillBehavior.HoldEnd;
rectAnimation.From = new Rect(xFrom, yFrom, wFrom, hFrom);
rectAnimation.To = new Rect(xTo, yTo, wTo, hTo);
rectAnimation.SetValue(Storyboard.TargetProperty, target);
rectAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("What-is-the-path?"));
storyboard.Children.Add(rectAnimation);
Thanks.
You do not need a Storyboard. Just call
Also note that it is usually not necessary to set the animation's
Fromproperty when you simply want to animate from the current value to a new value. The default value of theFillBehaviorproperty is also alreadyHoldEnd.