[FrmDoubleAnimationUsingKeyFrames.xaml]


<UserControl x:Class="RiaKeyFrames.FrmDoubleAnimationUsingKeyFrames"

    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">

                <DoubleAnimationUsingKeyFrames

                    Storyboard.TargetName="rect" Storyboard.TargetProperty="(Canvas.Left)"

                    Duration="00:00:10"

                >

                    <DoubleAnimationUsingKeyFrames.KeyFrames>

                        <LinearDoubleKeyFrame KeyTime="0:0:5" Value="250"></LinearDoubleKeyFrame>

                        <LinearDoubleKeyFrame KeyTime="0:0:10" Value="450"></LinearDoubleKeyFrame>

                    </DoubleAnimationUsingKeyFrames.KeyFrames>

                </DoubleAnimationUsingKeyFrames>

                <DoubleAnimationUsingKeyFrames

                    Storyboard.TargetName="rect" Storyboard.TargetProperty="(Canvas.Top)"

                    Duration="00:00:10"

                >

                    <DoubleAnimationUsingKeyFrames.KeyFrames>

                        <LinearDoubleKeyFrame KeyTime="0:0:5" Value="250"></LinearDoubleKeyFrame>

                        <LinearDoubleKeyFrame KeyTime="0:0:10" Value="450"></LinearDoubleKeyFrame>

                    </DoubleAnimationUsingKeyFrames.KeyFrames>

                </DoubleAnimationUsingKeyFrames>

            </Storyboard>

        </Canvas.Resources>

       

        <!-- 적용부 -->

        <Rectangle x:Name="rect" Width="50" Height="50" Canvas.Left="50" Canvas.Top="50"

            Fill="Red" Stroke="Blue" StrokeThickness="2" RadiusX="5" RadiusY="5"

        />

    </Canvas>

</UserControl>

 

 







[FrmDoubleAnimationUsingKeyFrames.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 RiaKeyFrames

{

    public partial class FrmDoubleAnimationUsingKeyFrames : UserControl

    {

        public FrmDoubleAnimationUsingKeyFrames()

        {

            InitializeComponent();

            this.Loaded += new RoutedEventHandler(FrmDoubleAnimationUsingKeyFrames_Loaded);

        }

 

        void FrmDoubleAnimationUsingKeyFrames_Loaded(object sender, RoutedEventArgs e)

        {

            sb.Begin();

        }

    }

}

 

 






Posted by holland14
: