我在XAML中定义了一个名为" MyRectangle"的矩形。点击后我执行以下代码:
auto animation = ref new Windows::UI::Xaml::Media::Animation::DoubleAnimation();
animation->From = 0.01;
animation->To = 5.50;
animation->AutoReverse = true;
auto beginTime = Windows::Foundation::TimeSpan();
beginTime.Duration = 0;
animation->BeginTime = beginTime;
auto duration = Windows::Foundation::TimeSpan();
duration.Duration = 20000*1000;
animation->Duration = duration;
auto storyboard = ref new Windows::UI::Xaml::Media::Animation::Storyboard();
auto scaleTransform = ref new Windows::UI::Xaml::Media::ScaleTransform();
MyRectangle->RenderTransform = scaleTransform;
storyboard->SetTargetProperty(animation, "(Rectangle.RenderTransform).(ScaleTransform.ScaleX)");
storyboard->SetTarget(animation, MyRectangle);
storyboard->SetTargetName(animation, "MyRectangle");
storyboard->SpeedRatio = 1.0;
storyboard->Begin();
然而,没有任何反应。我做错了什么?
答案 0 :(得分:0)
你必须添加"动画" (或更多动画)到"故事板"儿童:
storyboard-> CHILDREN->追加(动画);
这是C#等价物:
https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.animation.storyboard