【问题标题】:Cannot resolve TargetProperty when using StoryBoard in WinRT在 WinRT 中使用 StoryBoard 时无法解析 TargetProperty
【发布时间】:2012-03-27 05:09:25
【问题描述】:

我正在尝试在后面的代码中设置情节提要,但每次说都会抛出异常

“无法解析指定对象上的 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);

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

【问题讨论】:

    标签: c# wpf silverlight storyboard windows-runtime


    【解决方案1】:

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

    img.RenderTransform = new CompositeTransform();
    

    那你应该可以参考了。

    【讨论】:

    • 自从您第一次回答并且您刚刚解决了一个问题,我已经解决了好几个小时。非常感谢!
    猜你喜欢
    • 2017-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 2013-01-30
    • 2015-03-03
    • 1970-01-01
    相关资源
    最近更新 更多