我试图让这个动画工作但是出于某些原因,当Dispatch计时器调用时,没有任何事情发生,任何想法?
public static void Grass2(Canvas canvas, int boundry)
{
foreach (var element in canvas.Children.OfType<Image>())
{
var elementName = Regex.Split(element.Name, "_");
if (elementName[0] == "grass")
{
var skewGrass = new DoubleAnimation
{
From = 0,
To = boundry,
Duration = new Duration(TimeSpan.FromMilliseconds(100)),
RepeatBehavior = RepeatBehavior.Forever,
EasingFunction = new BackEase(),
AutoReverse = true
};
element.BeginAnimation(SkewTransform.AngleXProperty, skewGrass);
}
}
}
答案 0 :(得分:1)
您正尝试在Image类型的对象上设置SkewTransform.AngleXProperty
的动画。这不起作用,因为Image没有这个属性。但是,图像的RenderTransform
可能设置为SkewTransform,并且可以设置SkewTransform的动画:
...
// each element's RenderTransform must be a SkewTransform
var transform = (SkewTransform)element.RenderTransform;
transform.BeginAnimation(SkewTransform.AngleXProperty, skewGrass);