我有一个名为“b”的按钮,我要将背景从黑色变为白色,但它不起作用.
错误:
‘System.Windows.Media.Animation.ColorAnimation’ animation object cannot be used to animate property ‘Background’ because it is of incompatible type ‘System.Windows.Media.Brush’.
我的代码:
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()
有什么想法吗?