Exemplo n.º 1
0
        public static void AnimateTextColourOut(this DependencyObject source, System.Windows.Media.Color from, System.Windows.Media.Color to)
        {
            ColorAnimation anim = new ColorAnimation(from, to, kTextRolloverAnimationDuration);

            TextBlock[] txtBlocks = source.FindVisualChildren <TextBlock>(true);

            foreach (TextBlock txt in txtBlocks)
            {
                txt.Foreground = new SolidColorBrush(from);
                txt.Foreground.BeginAnimation(SolidColorBrush.ColorProperty, anim);
            }
            DispatcherTimer t = new DispatcherTimer();

            t.Interval = kTextRolloverAnimationDuration.TimeSpan;
            t.Tick    += ((d, a) =>
            {
                source.ClearAnimatedTextColour();
                t.Stop();
            });
            t.Start();
        }