Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF DoubleAnimation does not decrease the value after an animation
    text
    copied!<p>Consider the following simple WPF form, we will try to animate border1's Height:</p> <p><img src="https://i.stack.imgur.com/YYlZk.png" alt="alt text"></p> <p>This is the XAML for border1:</p> <pre><code>&lt;Border Margin="3" BorderBrush="Black" BorderThickness="1" Name="border1"&gt; &lt;Border.Style&gt; &lt;Style&gt; &lt;Setter Property="Control.Height" Value="50" /&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding X}" Value="1"&gt; &lt;DataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetProperty="Height" To="100" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.EnterActions&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding X}" Value="2"&gt; &lt;DataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetProperty="Height" To="200" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.EnterActions&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding X}" Value="3"&gt; &lt;DataTrigger.EnterActions&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetProperty="Height" To="300" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/DataTrigger.EnterActions&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Border.Style&gt; &lt;TextBlock Text="{Binding X}" /&gt; &lt;/Border&gt; </code></pre> <p>X is a normal <code>DependencyProperty</code> and buttons do their work without problem and TextBlock's content inside border1 shows the changed value.</p> <p>Now the <strong>problem</strong> is Height can be only <em>Increased</em>! For example by pressing 1, Height increases to 100, pressing 3 increases it to 300 <strong>but</strong> pressing 2 does not change the height.</p> <p>If I set the initial border1's height to, for example, 400, all buttons can decrease it to 100, 200 or 300 but after this stage no animation can decrease border's height.</p> <p>Am I missing some obvious point regarding WPF animation?</p>
 

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