views:

45

answers:

1

Is it possible to animate the StartPoint or EndPoint of a LinearGradientBrush? If so, what is the type of the Storyboard object used to animate the Points, as when I try the following I get "0,1" is not a valid value for Double, and I do realize I shouldn't be using the DoubleAnimationUsingKeyFrames type.

Current Code:

<UserControl.Triggers>
    <EventTrigger RoutedEvent="UserControl.Loaded">
        <BeginStoryboard>
            <Storyboard>
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
                                           Storyboard.TargetName="Path1" 
                                           Storyboard.TargetProperty="(Path.Stroke).(LinearGradientBrush.StartPoint)">
                    <SplineDoubleKeyFrame KeyTime="00:00:0" Value="0,1"/>
                    <SplineDoubleKeyFrame KeyTime="00:00:2" Value=".5,.5"/>
                    <SplineDoubleKeyFrame KeyTime="00:00:4" Value="1,0"/>
                    <SplineDoubleKeyFrame KeyTime="00:00:6" Value=".5,.5"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
                                           Storyboard.TargetName="Path1" 
                                           Storyboard.TargetProperty="(Path.Stroke).(LinearGradientBrush.EndPoint)">
                    <SplineDoubleKeyFrame KeyTime="00:00:0" Value="1,0"/>
                    <SplineDoubleKeyFrame KeyTime="00:00:2" Value=".5,.5"/>
                    <SplineDoubleKeyFrame KeyTime="00:00:4" Value="0,1"/>
                    <SplineDoubleKeyFrame KeyTime="00:00:6" Value=".5,.5"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</UserControl.Triggers>
+2  A: 

Yes. Just use "PointAnimationUsingKeyFrames" and "SplinePointKeyFrame" in your example above. It should work.

karmicpuppet
Thank you. That worked perfectly.
Patrick K