■ 브러시 애니메이션 만들기

----------------------------------------------------------------------------------------------------

<Window

    x:Class="TestProject.MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="600"

    Height="450"

    Title="브러시 애니메이션 만들기">

    <Grid>

        <TextBlock

            HorizontalAlignment="Center"

            VerticalAlignment="Center"

            FontSize="96"

            FontWeight="Bold"

            Text="Animation">

            <TextBlock.Foreground>

                <LinearGradientBrush x:Name="brush">

                    <LinearGradientBrush.GradientStops>

                        <GradientStop Color="Red"    />

                        <GradientStop Color="Orange" />

                        <GradientStop Color="Yellow" />

                        <GradientStop Color="Green" />

                        <GradientStop Color="Blue"   />

                        <GradientStop Color="Indigo" />

                        <GradientStop Color="Violet" />

                    </LinearGradientBrush.GradientStops>

                </LinearGradientBrush>

            </TextBlock.Foreground>

            <TextBlock.Triggers>

                <EventTrigger RoutedEvent="Path.Loaded">

                    <BeginStoryboard>

                        <Storyboard

                            TargetName="brush"

                            SpeedRatio="3">

                            <DoubleAnimation

                                Storyboard.TargetProperty="GradientStops[0].Offset"

                                RepeatBehavior="Forever"

                                Duration="0:0:7"

                                From="0"

                                To="1" />

                            <DoubleAnimation

                                Storyboard.TargetProperty="GradientStops[1].Offset"

                                RepeatBehavior="Forever"

                                BeginTime="0:0:1"

                                Duration="0:0:7"

                                From="0"

                                To="1" />

                            <DoubleAnimation

                                Storyboard.TargetProperty="GradientStops[2].Offset"

                                RepeatBehavior="Forever"

                                BeginTime="0:0:2"

                                Duration="0:0:7"

                                From="0"

                                To="1" />

                            <DoubleAnimation

                                Storyboard.TargetProperty="GradientStops[3].Offset"

                                RepeatBehavior="Forever"

                                BeginTime="0:0:3"

                                Duration="0:0:7"

                                From="0"

                                To="1" />

                            <DoubleAnimation

                                Storyboard.TargetProperty="GradientStops[4].Offset"

                                RepeatBehavior="Forever"

                                BeginTime="0:0:4"

                                Duration="0:0:7"

                                From="0"

                                To="1" />

                            <DoubleAnimation

                                Storyboard.TargetProperty="GradientStops[5].Offset"

                                RepeatBehavior="Forever"

                                BeginTime="0:0:5"

                                Duration="0:0:7"

                                From="0"

                                To="1" />

                            <DoubleAnimation

                                Storyboard.TargetProperty="GradientStops[6].Offset"

                                RepeatBehavior="Forever"

                                BeginTime="0:0:6"

                                Duration="0:0:7"

                                From="0"

                                To="1" />

                        </Storyboard>

                    </BeginStoryboard>

                </EventTrigger>

            </TextBlock.Triggers>

        </TextBlock>

    </Grid>

</Window>

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker