Daniel Perez
Daniel Perez

Reputation: 4332

Execute storyboard when databound property changes

Just this. I want that when the databound property Text of a TextBlock for example changes, an animation is performed to give some feedback to the user. How can this be done?? thanks!

Upvotes: 1

Views: 508

Answers (2)

Daniel Perez
Daniel Perez

Reputation: 4332

I found a way to do it using a PropertyChangedTrigger

<Interactivity:Interaction.Triggers>    
    <ec:PropertyChangedTrigger Binding="{Binding KnownMeaning}" >
         <eim:ControlStoryboardAction Storyboard="StaticResource Storyboard2}"/>
    </ec:PropertyChangedTrigger>
</Interactivity:Interaction.Triggers>

There may be a more elegant solution, but I think this is pretty straightforward

Upvotes: 5

Pol
Pol

Reputation: 5134

You can simply add event to ViewModel and start animation (Storyboard.Begin) in code-behind. Or even do it without extra event by adding handler of ViewModel.PropertyChanged in code-behind.

More advanced options are listed here: Re: How to Annimate (Storyboard.Begin() ) in MVVM.

Upvotes: 1

Related Questions