키프레임 (KeyFrame) - ColorAnimationUsingKeyFrames
.NET프로그래밍/Silverlight 3.0 2009. 12. 4. 09:42 |[FrmColorAnimationUsingKeyFrames.xaml]
<UserControl x:Class="RiaKeyFrames.FrmColorAnimationUsingKeyFrames"
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:0:3"
>
<ColorAnimationUsingKeyFrames.KeyFrames>
<LinearColorKeyFrame KeyTime="0:0:0" Value="Red"></LinearColorKeyFrame>
<LinearColorKeyFrame KeyTime="0:0:1" Value="Yellow"></LinearColorKeyFrame>
<LinearColorKeyFrame KeyTime="0:0:2" Value="Blue"></LinearColorKeyFrame>
<LinearColorKeyFrame KeyTime="0:0:3" Value="Red"></LinearColorKeyFrame>
</ColorAnimationUsingKeyFrames.KeyFrames>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Canvas.Resources>
<!-- 요소 -->
<Rectangle x:Name="rect" Width="100" Height="100" Canvas.Left="50" Canvas.Top="50"
Fill="Red"
/>
</Canvas>
</UserControl>
[FrmColorAnimationUsingKeyFrames.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 FrmColorAnimationUsingKeyFrames : UserControl
{
public FrmColorAnimationUsingKeyFrames()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(FrmColorAnimationUsingKeyFrames_Loaded);
}
void FrmColorAnimationUsingKeyFrames_Loaded(object sender, RoutedEventArgs e)
{
this.sb.Begin();
}
}
}
'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글
키프레임 (KeyFrame) - LinearDoubleKeyFrame (연속적인 움직임, 선형) (0) | 2009.12.04 |
---|---|
키프레임 (KeyFrame) - DoubleAnimationUsingKeyFrames (0) | 2009.12.04 |
여러개의 타임라인 사용하기 (0) | 2009.12.03 |
ColorAnimation (0) | 2009.12.03 |
PointAnimation (0) | 2009.12.03 |