■ EventTrigger 엘리먼트의 RoutedEvent 속성을 사용해 복권 긁는 효과를 만드는 방법을 보여준다.
▶ 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 |
<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="EventTrigger 엘리먼트 : RoutedEvent 속성을 사용해 복권 긁는 효과 사용하기" FontFamily="나눔고딕코딩" FontSize="16"> <Grid Width="500" Height="500" Background="RoyalBlue"> <Image Width="500" Height="500" Stretch="Fill" Source="sample.jpg" /> <WrapPanel SnapsToDevicePixels="True"> <WrapPanel.Resources> <Style TargetType="Rectangle"> <Setter Property="Width" Value="50" /> <Setter Property="Height" Value="50" /> <Setter Property="Fill" Value="Black" /> <Style.Triggers> <EventTrigger RoutedEvent="Rectangle.MouseEnter"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard Storyboard.TargetProperty="(Rectangle.Opacity)"> <DoubleAnimation To="0" Duration="0:0:0.5"/> <ColorAnimation Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" To="White" Duration="0:0:0.5" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Style.Triggers> </Style> </WrapPanel.Resources> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle /> </WrapPanel> </Grid> </Window> |