■ Storyboad 엘리먼트에서 스토리보드 객체를 대화형으로 제어하는 방법을 보여준다.
▶ 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 |
<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"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <Rectangle Name="rectangle" Width="100" Height="100" Fill="Blue"> </Rectangle> <StackPanel Margin="0 50 0 0" Orientation="Horizontal"> <Button Name="beginButton" Width="100" Height="30" Content="Begin" /> <Button Name="pauseButton" Margin="10 0 0 0" Width="100" Height="30" Content="Pause" /> <Button Name="resumeButton" Margin="10 0 0 0" Width="100" Height="30" Content="Resume" /> <Button Name="skipToFillButton" Margin="10 0 0 0" Width="120" Height="30" Content="Skip To Fill" /> <Button Name="stopButton" Margin="10 0 0 0" Width="100" Height="30" Content="Stop" /> </StackPanel> <StackPanel.Triggers> <EventTrigger SourceName="beginButton" RoutedEvent="Button.Click"> <BeginStoryboard Name="beginStoryboard"> <Storyboard> <DoubleAnimation Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Rectangle.Opacity)" Duration="00:00:05" From="1.0" To="0.0" /> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger SourceName="pauseButton" RoutedEvent="Button.Click"> <PauseStoryboard BeginStoryboardName="beginStoryboard" /> </EventTrigger> <EventTrigger SourceName="resumeButton" RoutedEvent="Button.Click"> <ResumeStoryboard BeginStoryboardName="beginStoryboard" /> </EventTrigger> <EventTrigger SourceName="skipToFillButton" RoutedEvent="Button.Click"> <SkipStoryboardToFill BeginStoryboardName="beginStoryboard" /> </EventTrigger> <EventTrigger SourceName="stopButton" RoutedEvent="Button.Click"> <StopStoryboard BeginStoryboardName="beginStoryboard" /> </EventTrigger> </StackPanel.Triggers> </StackPanel> </Window> |