XAML实现:
后台实现:
-
ObjectAnimationUsingKeyFrames animate = new ObjectAnimationUsingKeyFrames(); animate.Duration = new TimeSpan(0,0,4); animate.RepeatBehavior = RepeatBehavior.Forever; DiscreteObjectKeyFrame kf1 = new DiscreteObjectKeyFrame(Visibility.Visible, new TimeSpan(0, 0, 1)); DiscreteObjectKeyFrame kf2 = new DiscreteObjectKeyFrame(Visibility.Hidden, new TimeSpan(0, 0, 2)); DiscreteObjectKeyFrame kf3 = new DiscreteObjectKeyFrame(Visibility.Collapsed, new TimeSpan(0, 0,3)); animate.KeyFrames.Add(kf1); animate.KeyFrames.Add(kf2); animate.KeyFrames.Add(kf3); Bord11.BeginAnimation(Border.VisibilityProperty, animate);