StoryboardCompletedTrigger and SetPropertyAction

Share on:

I’ve spent a couple of hours on WinRTTriggers tonight and added a couple of features that have been requested recently, StoryboardCompletedTrigger and SetPropertyAction.

StoryboardCompletedTrigger

This trigger allows to to fire an action when a storyboard completes – you can use it like this:

1<Triggers:StoryboardCompletedTrigger Storyboard="{StaticResource FlashNameChanged}">
2    <!-- insert your action(s) here -->
3</Triggers:StoryboardCompletedTrigger>

SetPropertyAction

This allows you to react to a trigger by setting a property on an object – most likely your view model:

1<Triggers:Interactions.Triggers>
2    <Triggers:PropertyChangedTrigger Binding="{Binding Person.Name}">
3        <Triggers:SetPropertyAction Target="{Binding}" 
4                                    PropertyName="HasChangedName" Value="true" />
5    </Triggers:PropertyChangedTrigger>
6</Triggers:Interactions.Triggers>

There’s nothing stopping you binding the new value to something another property on your view model, either:

1<Triggers:Interactions.Triggers>
2    <Triggers:PropertyChangedTrigger Binding="{Binding Person.Name}">
3        <Triggers:SetPropertyAction Target="{Binding}" 
4                          PropertyName="ChangeCount" 
5                          Value="{Binding NextChangeCount}" />
6    </Triggers:PropertyChangedTrigger>
7</Triggers:Interactions.Triggers>

Of course you can combine these with all the other triggers and actions in the WinRTTriggers library in a variety of ways – hopefully these plug a couple of gaps that people have needed filled!

Hope this helps - I’m always interested in hearing how you get on with using WinRTTriggers in your Windows 8 applications!