Note that there are some explanatory texts on larger screens.

plurals
  1. POuse data trigger control the storyboard, but only trigger one time
    text
    copied!<p>I use a data trigger to control some storyboards, but it only can be trigger one time.</p> <pre><code> &lt;Style x:Key="PropertyTriggerExampleButtonStyle" TargetType="{x:Type Button}"&gt; &lt;Setter Property="Width" Value="200" /&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding para}" Value="0"&gt; &lt;DataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetProperty="Width" To="500" Duration="0:0:1" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.EnterActions&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding para}" Value="1"&gt; &lt;DataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetProperty="Width" To="200" Duration="0:0:1" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.EnterActions&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;Button Style="{StaticResource PropertyTriggerExampleButtonStyle}"&gt; button width will be changed &lt;/Button&gt; </code></pre> <p>The para is a variable (already implement INotifyPropertyChanged interface)which will be control by another button. its value is 0 or 1.</p> <p>But when I click the button to change the para value, the storyboard only trigger one time for every value(0 and 1). It will never trigger later.</p> <p>If I put the second storyboard into ExitActions tag of the first data trigger. it will work well. But I have more than 2 storyboard need control......</p> <p>following code works well,but I need control many storyboard (more than 2) according to different value....</p> <pre><code>&lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding para}" Value="0"&gt; &lt;DataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetProperty="Width" To="500" Duration="0:0:1" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.EnterActions&gt; &lt;DataTrigger.ExitActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetProperty="Width" To="200" Duration="0:0:1" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.ExitActions&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload