■ ColorAnimation 엘리먼트 사용하기

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

<Window Name="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="ColorAnimation 엘리먼트 사용하기">

    <Window.Resources>

        <Style TargetType="{x:Type RadioButton}">

            <Setter Property="Margin" Value="10" />

        </Style>

    </Window.Resources>

    <StackPanel

        HorizontalAlignment="Center"

        VerticalAlignment="Center"

        Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">

        <RadioButton Content="Red">

            <RadioButton.Triggers>

                <EventTrigger RoutedEvent="RadioButton.Checked">

                    <BeginStoryboard>

                        <Storyboard>

                            <ColorAnimation

                                Storyboard.TargetName="window"

                                Storyboard.TargetProperty="Background.Color"

                                Duration="0:0:1"

                                To="Red" />

                        </Storyboard>

                    </BeginStoryboard>

                </EventTrigger>

            </RadioButton.Triggers>

        </RadioButton>

        <RadioButton Content="Green">

            <RadioButton.Triggers>

                <EventTrigger RoutedEvent="RadioButton.Checked">

                    <BeginStoryboard>

                        <Storyboard>

                            <ColorAnimation

                                Storyboard.TargetName="window"

                                Storyboard.TargetProperty="Background.Color"

                                Duration="0:0:1"

                                To="Green" />

                        </Storyboard>

                    </BeginStoryboard>

                </EventTrigger>

            </RadioButton.Triggers>

        </RadioButton>

        <RadioButton Content="Blue">

            <RadioButton.Triggers>

                <EventTrigger

                    RoutedEvent="RadioButton.Checked">

                    <BeginStoryboard>

                        <Storyboard>

                            <ColorAnimation

                                Storyboard.TargetName="window"

                                Storyboard.TargetProperty="Background.Color"

                                Duration="0:0:1"

                                To="Blue" />

                        </Storyboard>

                    </BeginStoryboard>

                </EventTrigger>

            </RadioButton.Triggers>

        </RadioButton>

    </StackPanel>

</Window>

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

Posted by 사용자 icodebroker

댓글을 달아 주세요