Question

I am trying to animate the Fill property of a path. What I have so far is a ColorAnimation that works well. The target property is (Shape.Fill).(SolidColorBrush.Color) and I set it to a value of "#999999" (just an example color).

The problem comes from the fact that I'd like to set the value to "{TemplateBinding Background}". Since Background is a brush and the property I'm targeting is a color this just results in no color in the animation.

I would be happy if I could just figure out how to set the value to the color portion of the background brush. Any ideas?

BTW, this is in a control template for a ToggleButton.

Thanks, David

Was it helpful?

Solution

You could create a class that implements IValueConverter, and set this as the Converter property of the binding. You would still set the binding to the Background, but that would in turn be passed to your converter. The converter can extract the color from the brush, and then return that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top