You need to convert the rectangle color to Windows Phone 7
I have a rectangle and I have a storyboard:
<Storyboard x:Key="PressAndHoldColorBar"> <ColorAnimationUsingKeyFrames Duration="0:0:10" FillBehavior="Stop" Storyboard.TargetName="rectWarning" Storyboard.TargetProperty="Fill"> <LinearColorKeyFrame KeyTime="0:0:0" Value="Green" /> <LinearColorKeyFrame KeyTime="0:0:7" Value="Yellow" /> <LinearColorKeyFrame KeyTime="0:0:10" Value="Red" /> </ColorAnimationUsingKeyFrames> </Storyboard> <Rectangle Height="100" HorizontalAlignment="Left" Margin="12,328,0,0" Name="rectWarning" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="200"> I want this color change to happen when another button is pressed, so I'm trying to call the code programmatically:
s = (Storyboard)this.Resources["PressAndHoldColorBar"]; s.Begin(); I narrowed it down to Storyboard.TargetName and TargetProperty in the first snippet (I think). I just need help figuring out what to do to get it working completely.
It revealed:
<Storyboard x:Name="PressAndHoldColorBar"> <ColorAnimationUsingKeyFrames Duration="0:0:10" FillBehavior="Stop" Storyboard.TargetName="rectWarning" Storyboard.TargetProperty="(Fill).(SolidColorBrush.Color)"> <LinearColorKeyFrame KeyTime="0:0:0" Value="Green" /> <LinearColorKeyFrame KeyTime="0:0:7" Value="Yellow" /> <LinearColorKeyFrame KeyTime="0:0:10" Value="Red" /> </ColorAnimationUsingKeyFrames> </Storyboard> You must use (fill). (SolidColorBrush.Color). This is not like (Shape.Fill).