I have a button named "b" whose background I want to change from black to white, but it does not work.
Error:
The animation object "System.Windows.Media.Animation.ColorAnimation" cannot be used to animate the property "Background" because it has the incompatible type "System.Windows.Media.Brush".
My code is:
Dim changeColor As New Animation.ColorAnimation changeColor.From = Colors.Black changeColor.To = Colors.White changeColor.Duration = TimeSpan.FromSeconds(0.2) Animation.Storyboard.SetTarget(changeColor, b) Animation.Storyboard.SetTargetProperty(changeColor, New PropertyPath(BackgroundProperty)) Dim sb As New Animation.Storyboard sb.Children.Add(changeColor) sb.Begin()
Any ideas?
source share