Well, thatβs how I solved the problem. This is probably one of the ugliest codes I've ever written, so feel free to suggest something better.
I created a converter that I associate with duration using a boolean that enables / disables the animation. Something like that:
class AnimationEnablerConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { bool enableAnimation = (bool)value; if (enableAnimation) { return new System.Windows.Duration(new TimeSpan(0, 0, 0, 0, 200)); } else { return new System.Windows.Duration(new TimeSpan(0, 0, 0, 0, 0)); } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion }
And xaml:
<ColorAnimation AutoReverse="True" From="#1F1F1F" To="#FFFF88" Duration="{Binding IsAnimationEnabled, Converter={StaticResource anim2}}" Storyboard.TargetProperty="Background.Color" FillBehavior="Stop" />
source share