I need to animate the text color of a custom control between two colors that are read from two properties of a Brushcustom control. My resources look like this:
<SolidColorBrush x:Key="TextBrush">{TemplateBinding Foreground}</SolidColorBrush>
<SolidColorBrush x:Key="AltTextBrush">{TemplateBinding ForegroundAlt}</SolidColorBrush>
Right now, I'm trying to animate using ColorAnimation:
<ColorAnimation Storyboard.TargetName="MyControlText" Storyboard.TargetProperty="Foreground" To="{StaticResource AltTextBrush}" Duration="00:00:00.3000000" />
It seems that ColorAnimation wants an object Color, not the Brushone I'm trying to pass. I think I can write IValueConverterto get the color from the brush, but before I do this, I want to see if there is an easier way to do this work. Here are my questions:
Is there an easy way to animate between two brush resources, or do I need to extract color for the animation?
- If I need to extract colors, is this the best IValueConverter practice?
- And finally, have I taken the right path or is there a simpler solution to this problem?
Thank you for your help.
source
share