Ugrás a tartalomhoz

.NET Programming Technologies

Gergely Kovásznai, Csaba Biró

Eszterházy Károly College

EventTrigger

EventTrigger

The event trigger is slightly different from the previously known studies. These triggers allows to control animations started by managed events.  

Example X.5 EventTrigger 1

<Grid>

     <ToggleButton Width="60" Height="40" Content="Speech">

         <ToggleButton.Triggers>

              <EventTrigger RoutedEvent="ToggleButton.Checked">

                  <SoundPlayerAction Source="c:\windows\media\Speech On.wav" />

              </EventTrigger>

              <EventTrigger RoutedEvent="ToggleButton.Unchecked">

                  <SoundPlayerAction Source="c:\windows\media\Speech Off.wav" />

              </EventTrigger>

         </ToggleButton.Triggers>

    </ToggleButton>

</Grid>

Example X.6 EventTrigger 2

<Image Source="Neptunusz.jpg" Width="100" >

     <Image.Triggers>

        <EventTrigger RoutedEvent="Image.MouseEnter">

           <BeginStoryboard>

             <Storyboard Storyboard.TargetProperty="Width">

               <DoubleAnimation  Duration="0:0:3" To="200"  />

             </Storyboard>

           </BeginStoryboard>

        </EventTrigger>

        <EventTrigger RoutedEvent="Image.MouseLeave">

           <BeginStoryboard>

             <Storyboard Storyboard.TargetProperty="Width">

                 <DoubleAnimation  To="100" Duration="0:0:3" />

              </Storyboard>

         </BeginStoryboard>

       </EventTrigger>

    </Image.Triggers>

</Image>