Monday, 2 April 2012

EventTrigger In Wpf:-

If you want to perform animations on mouse events we can use EventTriggers.Using EventTriggers we can start,pause and stop the storyboards.The following example  performs simple animations on mouse enter and mouse leave events.

<Window x:Class="WpfEventTriggers.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <Rectangle Name="rMain" Width="100" Height="100">
                <SolidColorBrush x:Name="MySolidColorBrush" Color="Green" />
                <!--Begins the storyboard on mouseenter-->
                <EventTrigger RoutedEvent="MouseEnter">
                    <BeginStoryboard  Name="sbMain">
                                            From="100" To="200" Duration="0:0:1" >

                <!--Stops the storyboard on mouseleave-->
                <EventTrigger RoutedEvent="MouseLeave">
                            <!--Specify storyboard name-->

Let me know, if you have any feedback. Mail me for source code. Enjoy reading my articles…

No comments:

Post a Comment