protected override void OnInitialized() { base.OnInitialized(); ColorAnimation colorAnim; this.ColorAnimation = Storyboard.Register(this); colorAnim = new ColorAnimation(); colorAnim.From = Color.Blue; colorAnim.To = Color.Magenta; colorAnim.Duration = TimeSpan.FromSeconds(2); colorAnim.AutoReverse = true; colorAnim.RepeatBehavior = RepeatBehavior.Forever; this.ColorAnimation.Children.Add(colorAnim); Storyboard.SetTarget(colorAnim, this); Storyboard.SetTargetProperty(colorAnim, new PropertyPath(new DependencyProperty[] { Window.BackgroundProperty, Photon.Media.SolidColorBrush.ColorProperty })); }
/// <summary> /// Creates the register a new <see cref="Storyboard"/> for the specified <see cref="IUIElement"/> /// </summary> /// <param name="element">The <see cref="IUIElement"/> for which to create the <see cref="Storyboard"/></param> /// <returns>The <see cref="Storyboard"/> that has been registered into the specified <see cref="IUIElement"/></returns> public static Storyboard Register(IUIElement element) { Storyboard storyboard; storyboard = new Storyboard(); element.AnimationClocks.Add(storyboard); return storyboard; }