动态添加的控件,出现时候添加动画
Floor floor = new Floor(); floor.Height = 10; floor.Width = 10; double delt = 2 * i * Math.PI / buildings.Count; this.LayoutRoot.Children.Add(floor); double X = CenterX - floor.Width / 2 + 50 * Math.Cos(delt); double Y = CenterY - floor.Height / 2 + 50 * Math.Sin(delt); Canvas.SetLeft(floor, X); Canvas.SetTop(floor, Y);
Storyboard storyboard = new Storyboard(); //storyboard.Duration = new Duration(TimeSpan.FromSeconds(0.5)); DoubleAnimation slideOut = new DoubleAnimation(); slideOut.SetValue(Storyboard.TargetNameProperty, "floor"); slideOut.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.Opacity)")); slideOut.Duration = new Duration(TimeSpan.FromSeconds(0.5)); slideOut.To = 0; slideOut.From = 1; storyboard.Children.Add(slideOut); LayoutRoot.Resources.Add("Storyboard", storyboard); storyboard.Begin();