LinearGradientBrush animation : LinearGradientBrush « Windows Presentation Foundation « VB.Net Tutorial






<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Rectangle Name="rect"
               Canvas.Left="96" Canvas.Top="96" 
               Width="192" Height="192"
               Stroke="Black">
        <Rectangle.Fill>
            <LinearGradientBrush x:Name="brush">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Offset="0" Color="Red" />
                    <GradientStop Offset="1" Color="Blue" />
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Rectangle.Fill>
    </Rectangle>

    <Canvas.Triggers>
        <EventTrigger RoutedEvent="Canvas.Loaded">
            <BeginStoryboard>
                <Storyboard>

                    <PointAnimation Storyboard.TargetName="brush"
                                    Storyboard.TargetProperty="StartPoint"
                                    From="0 0" To="1 0" Duration="0:0:5"
                                    AutoReverse="True"
                                    RepeatBehavior="Forever" />

                    <PointAnimation Storyboard.TargetName="brush"
                                    Storyboard.TargetProperty="EndPoint"
                                    From="1 1" To="0 1" Duration="0:0:5"
                                    AutoReverse="True"
                                    RepeatBehavior="Forever" />

                    <ColorAnimation 
                        Storyboard.TargetName="brush"
                        Storyboard.TargetProperty="GradientStops[0].Color"
                        From="Red" To="Blue" Duration="0:0:1" 
                        AutoReverse="True"
                        RepeatBehavior="Forever" />

                    <ColorAnimation 
                        Storyboard.TargetName="brush"
                        Storyboard.TargetProperty="GradientStops[1].Color"
                        From="Blue" To="Red" Duration="0:0:1" 
                        AutoReverse="True"
                        RepeatBehavior="Forever" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Canvas.Triggers>
</Canvas>
WPF Linear Gradient Brush Animation








16.81.LinearGradientBrush
16.81.1.LinearGradientBrush for Rectangle.StrokeLinearGradientBrush for Rectangle.Stroke
16.81.2.LinearGradientBrush animationLinearGradientBrush animation
16.81.3.LinearGradientBrush ExamplesLinearGradientBrush Examples
16.81.4.Text Box with LinearGradientBrushText Box with LinearGradientBrush
16.81.5.Fill with diagonal LinearGradientBrushFill with diagonal LinearGradientBrush
16.81.6.Rectangle with LinearGradientBrushRectangle with LinearGradientBrush
16.81.7.LinearGradientBrush.RelativeTransformLinearGradientBrush.RelativeTransform
16.81.8.LinearGradientBrush.Transform RotateTransformLinearGradientBrush.Transform RotateTransform
16.81.9.LinearGradientBrush With 0.5 Offset for WhiteLinearGradientBrush With 0.5 Offset for White
16.81.10.Stroke with horizontal multi-color LinearGradientBrushStroke with horizontal multi-color LinearGradientBrush
16.81.11.Fill the overline decoration with a linear gradient brush in VBFill the overline decoration with a linear gradient brush in VB
16.81.12.Fill the baseline decoration with a linear gradient brush in VBFill the baseline decoration with a linear gradient brush in VB