using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace GridViewAnimation
{
    public partial class AnimationUserControl : UserControl
    {
        public AnimationUserControl()
        {
            InitializeComponent();
        }

        private void UpdateUI()
        {
             ((Storyboard)this.Resources["RedToTransparent"]).Begin();
        }

        public bool ShouldAnimateCell
        {
            get { return (bool)GetValue(ShouldAnimateCellProperty); }
            set { SetValue(ShouldAnimateCellProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ShouldAnimateCell.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ShouldAnimateCellProperty =
            DependencyProperty.Register("ShouldAnimateCell", typeof(bool), typeof(AnimationUserControl), new PropertyMetadata(OnShouldAnimateCellChanged));

        private static void OnShouldAnimateCellChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as AnimationUserControl).UpdateUI();
        }
    }
}
