我有一个名为“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()
有什么想法?
不工作! :( – Cobold 2011-05-09 19:28:14
其实它的工作!我没有写在正确的外壳。谢谢!:) – Cobold 2011-05-09 19:30:45