tags:

views:

1246

answers:

1

Well i have a DataTemplate that is for a class that implements INotifyPropertyChanged is there any way to trigger a storyboard when a property changes and diffrent storeboard on diffrent values (its a bool in this case)?

And is there any way to trigger a storyboard on startup depending on values on the class that the datatemplate is made for?

+3  A: 

Yes, you can do that.

Add a DataTrigger and bind to the respective property. Here's an example:

<DataTemplate.Triggers>
 <DataTrigger Binding="{Binding Path=MyProperty}" Value="True">
  <BeginStoryboard Storyboard="{StaticResource myStoryboard}"/>
 </DataTrigger>
</DataTemplate.Triggers>

You can set the value to test for to anything you want. So you could set the storyboard to begin when your value changes to false. You can add as many DataTriggers (or other triggers) as you want.

Notice that in my example I reference a dummy property and storyboard.

When the property changes, the binding will be updated and will fire the trigger because of the databinding.

This technique should also work at startup.

Josh G
will this work even if all values are set when the listbox gets the object?
Petoj
I believe the storyboard would be fired when the object is acquired. Try it and see.
Josh G