我有一个Window> grid>矩形,名为(rect1)
如何使用故事板放大这个
错误:其他信息:没有适用的名称范围来解析名称' rect1'
GetTimeZoneInformationForYear
答案 0 :(得分:1)
您应该像这样设置宽度和高度属性:
DoubleAnimation widthAnimation = new DoubleAnimation
{
From = 0,
To = rect1.ActualWidth*2,
Duration = TimeSpan.FromSeconds(5)
};
DoubleAnimation heightAnimation = new DoubleAnimation
{
From = 0,
To = rect1.ActualHeight*2,
Duration = TimeSpan.FromSeconds(5)
};
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(Rectangle.WidthProperty));
Storyboard.SetTarget(widthAnimation, rect1);
Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(Rectangle.HeightProperty));
Storyboard.SetTarget(heightAnimation, rect1);
Storyboard buttonEnlargeStoryboard = new Storyboard();
buttonEnlargeStoryboard.SpeedRatio = 1;
buttonEnlargeStoryboard.Children.Add(widthAnimation);
buttonEnlargeStoryboard.Children.Add(heightAnimation);
buttonEnlargeStoryboard.Begin();