繁体   English   中英

在WinRT中使用StoryBoard时无法解析TargetProperty

[英]Cannot resolve TargetProperty when using StoryBoard in WinRT

我试图在代码后面设置一个故事板,但是每次都会抛出异常

“无法解析指定对象上的TargetProperty(UIElement.RenderTransform)。(CompositeTransform.ScaleX)。”

这是我的代码:

Image img = new Image() { Source = image.Source, Name="image"+i.ToString()};
var pointedStoryboard = new Storyboard();
var doubleAnnimationX = new DoubleAnimation();
doubleAnnimationX.Duration = TimeSpan.FromMilliseconds(500);
doubleAnnimationX.To = 2;
pointedStoryboard.Children.Add(doubleAnnimationX);
Storyboard.SetTarget(doubleAnnimationX, img);
Storyboard.SetTargetProperty(doubleAnnimationX, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");

我也试过了

Storyboard.SetTargetName(doubleAnnimationX, "image" + i.ToString());

代替

Storyboard.SetTarget(doubleAnnimationX, img);

但它也确实有效,不知道该怎么做,如果你帮助我,我会非常感激! 提前致谢 。

您需要首先向图像添加复合变换。

img.RenderTransform = new CompositeTransform();

然后你应该能够引用它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM