[MainPage.xaml]


<UserControl x:Class="RiaLinearDoubleKeyFrame.MainPage"

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

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

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Canvas x:Name="LayoutRoot" Background="White">

        <!-- 리소스 -->

        <Canvas.Resources>

            <Storyboard x:Name="sb">

                <ColorAnimationUsingKeyFrames

                    Storyboard.TargetName="rect"

                    Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)"

                    Duration="0.00:00:10.0">

                    <ColorAnimationUsingKeyFrames.KeyFrames>

                        <LinearColorKeyFrame KeyTime="0:0:0" Value="red" />

                        <LinearColorKeyFrame KeyTime="0:0:2" Value="Yellow" />

                        <LinearColorKeyFrame KeyTime="0:0:4" Value="Green" />

                        <LinearColorKeyFrame KeyTime="0:0:6" Value="Silver" />

                        <LinearColorKeyFrame KeyTime="0:0:8" Value="Orange" />

                        <LinearColorKeyFrame KeyTime="0:0:10" Value="SkyBlue" />

                    </ColorAnimationUsingKeyFrames.KeyFrames>

                </ColorAnimationUsingKeyFrames>

            </Storyboard>

        </Canvas.Resources>

                

        <!-- 요소 -->

        <Rectangle x:Name="rect" Width="30" Height="30" Fill="Red">

        </Rectangle>

    </Canvas>

</UserControl>

 

 






[MainPage.xaml.cs]


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaLinearDoubleKeyFrame

{

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

 

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

        }

 

        void MainPage_Loaded(object sender, RoutedEventArgs e)

        {

            sb.Begin();

        }

    }

}

 

 







Posted by holland14
: