■ Timeline 엘리먼트의 SpeedRatio 속성을 사용하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="800" Height="600" Title="TestProject" FontFamily="나눔고딕코딩" FontSize="16"> <Window.Resources> <DrawingBrush x:Key="GridDrawingBrushKey" Viewport="0 0 10 10" ViewportUnits="Absolute" TileMode="Tile"> <DrawingBrush.Drawing> <DrawingGroup> <DrawingGroup.Children> <GeometryDrawing Brush="#99ffffff"> <GeometryDrawing.Geometry> <RectangleGeometry Rect="0 0 1 1" /> </GeometryDrawing.Geometry> </GeometryDrawing> <GeometryDrawing Brush="#99ccccff" Geometry="M 0 0 L 1 0 1 0.1 0 0.1 Z" /> <GeometryDrawing Brush="#99ccccff" Geometry="M 0 0 L 0 1 0.1 1 0.1 0 Z" /> </DrawingGroup.Children> </DrawingGroup> </DrawingBrush.Drawing> </DrawingBrush> </Window.Resources> <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="500"> <StackPanel Background="{StaticResource GridDrawingBrushKey}"> <TextBlock>Speed="1"</TextBlock> <Rectangle Name="defaultSpeedRectangle" HorizontalAlignment="Left" Margin="0 10 0 0" Width="20" Height="20" Fill="#aa3333ff" /> <TextBlock Margin="0 20 0 0">Speed="2"</TextBlock> <Rectangle Name="fasterRectangle" HorizontalAlignment="Left" Margin="0 10 0 0" Width="20" Height="20" Fill="#aa3333ff" /> <TextBlock Margin="0 20 0 0">Speed="0.5"</TextBlock> <Rectangle Name="slowerRectangle" HorizontalAlignment="Left" Margin="0 10 0 0" Width="20" Height="20" Fill="#aa3333ff" /> <Button HorizontalAlignment="Left" Margin="0 30 0 0"> Restart Animations <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="defaultSpeedRectangle" Storyboard.TargetProperty="(Rectangle.Width)" Duration="00:00:02" From="20" To="400" SpeedRatio="1" /> <DoubleAnimation Storyboard.TargetName="fasterRectangle" Storyboard.TargetProperty="(Rectangle.Width)" Duration="00:00:02" From="20" To="400" SpeedRatio="2" /> <DoubleAnimation Storyboard.TargetName="slowerRectangle" Storyboard.TargetProperty="(Rectangle.Width)" Duration="00:00:02" From="20" To="400" SpeedRatio="0.5" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> </StackPanel> </Grid> </Window> |