Why below code doesn’t change ScaleY to 1?
var transform = new ScaleTransform { ScaleY = 0 };
var story = new Storyboard();
var animation = new DoubleAnimation {
Duration = new Duration(new TimeSpan(0)), To = 1 };
Storyboard.SetTarget(animation, transform);
Storyboard.SetTargetProperty(animation, new PropertyPath("ScaleY"));
story.Children.Add(animation);
story.Begin();
I use transform indirectly: it use for render some UIElements and kept in their DependencyProperty.
Does it perhaps work if you drop the Storyboard and just call BeginAnimation directly?
Note that this will only have any effect if the animation’s FillBehavior has a value of
HoldEnd. Otherwise the animated property will immediately revert back to its local value (which is 0 here). FortunatelyHoldEndis the default value forFillBehavior.And of course the
transformshould be used somewhere.