■ DoubleAnimation 엘리먼트의 IsCumulative 속성을 사용하는 방법을 보여준다.
▶ 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
<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="550"> <StackPanel Background="{StaticResource GridDrawingBrushKey}"> <TextBlock xml:space="preserve"> <DoubleAnimation Duration="00:00:01" From="100" By="100" RepeatBehavior="4x" AutoReverse="True" <Bold>IsCumulative="True"</Bold> /> </TextBlock> <Rectangle Name="withIsCumulativeRectangle" HorizontalAlignment="Left" Margin="0 10 0 0" Width="100" Height="20" Fill="#aa3333ff" /> <StackPanel Margin="0 5 0 0"> <Path StrokeThickness="2" Stroke="Black" Data="M 0 0 L 100 0" /> <Path StrokeThickness="2" Stroke="Black" Data="M 100 0 L 100 8" /> <Path StrokeThickness="2" Stroke="Black" Data="M 100 -9 L 200 -9" /> <Path StrokeThickness="2" Stroke="Black" Data="M 200 -9 L 200 0" /> <Path StrokeThickness="2" Stroke="Black" Data="M 200 -9 L 300 -9" /> <Path StrokeThickness="2" Stroke="Black" Data="M 300 -9 L 300 0" /> <Path StrokeThickness="2" Stroke="Black" Data="M 300 -9 L 400 -9" /> <Path StrokeThickness="2" Stroke="Black" Data="M 400 -9 L 400 0" /> <Path Stroke="Black" StrokeThickness="2" Data="M 400 -9 L 500 -9" /> <Path Stroke="Black" StrokeThickness="2" Data="M 500 -9 L 500 0" /> </StackPanel> <TextBlock xml:space="preserve"> <DoubleAnimation Duration="00:00:01" From="100" By="100" RepeatBehavior="4x" AutoReverse="True" <Bold>IsCumulative="False"</Bold> /> </TextBlock> <Rectangle Name="withoutIsCumulative" HorizontalAlignment="Left" Margin="0 10 0 0" Width="100" Height="20" Fill="#aa3333ff" /> <StackPanel Margin="0 5 0 0"> <Path StrokeThickness="2" Stroke="Black" Data="M 0 0 L 100 0" /> <Path StrokeThickness="2" Stroke="Black" Data="M 100 0 L 100 8" /> <Path StrokeThickness="2" Stroke="Black" Data="M 100 -9 L 200 -9" /> <Path StrokeThickness="2" Stroke="Black" Data="M 200 -9 L 200 0" /> <Path StrokeThickness="2" Stroke="Black" Data="M 200 -9 L 300 -9" /> <Path StrokeThickness="2" Stroke="Black" Data="M 300 -9 L 300 0" /> <Path StrokeThickness="2" Stroke="Black" Data="M 300 -9 L 400 -9" /> <Path StrokeThickness="2" Stroke="Black" Data="M 400 -9 L 400 0" /> <Path StrokeThickness="2" Stroke="Black" Data="M 400 -9 L 500 -9" /> <Path StrokeThickness="2" Stroke="Black" Data="M 500 -9 L 500 0" /> </StackPanel> <Button HorizontalAlignment="Left" Margin="0 30 0 0" Width="180" Height="30"> Restart Animations <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="withIsCumulativeRectangle" Storyboard.TargetProperty="(Rectangle.Width)" Duration="00:00:01" From="100" By="100" RepeatBehavior="4x" AutoReverse="True" IsCumulative="True" /> <DoubleAnimation Storyboard.TargetName="withoutIsCumulative" Storyboard.TargetProperty="(Rectangle.Width)" Duration="00:00:01" From="100" By="100" RepeatBehavior="4x" AutoReverse="True" IsCumulative="False" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> </StackPanel> </Grid> </Window> |