The event triggers mechanism allows you to begin an animation when an event is fired by a view element.
It is based on the event to command binding mechanism. You just need to specify a special command called TriggerCommand.

Here is a short version of the sample XAML:
<Border mvvm:EventBinding.PointerPressed="{StaticResource PointerPressedTriggerCommand}"/>

or
<Border>
    <mvvm:EventBinding.PointerPressed>
        <mvvm:TriggerCommand Storyboard="{StaticResource FadeOut}"/>
    </mvvm:EventBinding.PointerPressed>
</Border>

Here is a full sample:
<Grid>
    <FrameworkElement.Resources>
        <Storyboard x:Key="FadeOut">
            <PointerDownThemeAnimation Storyboard.TargetName="MyElement"/>
        </Storyboard>
        <Storyboard x:Key="FadeIn">
            <PointerUpThemeAnimation Storyboard.TargetName="MyElement"/>
        </Storyboard>
    </FrameworkElement.Resources>
    
    <Border x:Name="MyElement" Width="100" Height="100" Background="Red">

        <mvvm:EventBinding.PointerPressed>
            <mvvm:TriggerCommand Storyboard="{StaticResource FadeOut}"/>
        </mvvm:EventBinding.PointerPressed>

        <mvvm:EventBinding.PointerReleased>
            <mvvm:TriggerCommand Storyboard="{StaticResource FadeIn}"/>
        </mvvm:EventBinding.PointerReleased>

    </Border>
</Grid>

Last edited Jan 24, 2013 at 9:43 PM by mglukhankov, version 1

Comments

No comments yet.