I'm tring to use a ColorAnimation programmatically to animate a cell, but I got this when I perform storyboard.Begin()
'System.Windows.Media.Animation.ColorAnimation' animation object cannot be used to animate property 'Background' because it is of incompatible type 'System.Windows.Media.Brush'.
I've defined my ColorAnimation
as
var storyBoard = new Storyboard();
ColorAnimation colorAnimation = new ColorAnimation
{
From = Colors.Red,
To = Colors.CornflowerBlue,
Duration = TimeSpan.FromSeconds(1),
FillBehavior = FillBehavior.Stop
};
and on it's usage I do
if (column.UniqueName != "_ID")
{
var animation = animationMapping[column.UniqueName].Animation;
var storyboard = animationMapping[column.UniqueName].Storyboard;
Storyboard.SetTarget(animation, cell.Content as TextBlock);
//Storyboard.SetTargetProperty(animation,
// new PropertyPath((TextBlock.Foreground).Color"));
PropertyPath colorTargetPath = new PropertyPath(TextBlock.BackgroundProperty);
Storyboard.SetTargetProperty(animation, colorTargetPath);
storyboard.Begin();
}
What paramater do I have to pass to the new PropertyPath
? I've tried to follow this example but without any luck.