Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><H1>Update</H1></p> <p>Part of the issue is the storyboard in the DataTrigger is not being stopped, so (the last DataTrigger defined) is always holding the Height's 'animated' value.</p> <p>Adding a StopStoryboard in the exit action fixes part of it. You can now switch between all three heights again... but the animation always starts from the Height's base value (which is clearly not what you want). You want it to start from where it was last set at.</p> <p>The following MSDN article explains the second issue pretty well: <a href="http://msdn.microsoft.com/en-us/library/aa970493.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa970493.aspx</a></p> <p><H2>Good Solution-</H2> EventTriggers on your three buttons seem to work better and doesn't have the problems that the DataTrigger encounters (plus you don't even need the dependency property 'X' anymore!)</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&gt; &lt;/Border.Style&gt; &lt;TextBlock Text="{Binding X}" /&gt; &lt;/Border&gt; </code></pre> <p>and</p> <pre><code>&lt;StackPanel Orientation="Horizontal"&gt; &lt;Button Content="1" Width="50"&gt; &lt;Button.Triggers&gt; &lt;EventTrigger RoutedEvent="Button.Click"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="border1" Storyboard.TargetProperty="Height" To="100"/&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/Button.Triggers&gt; &lt;/Button&gt; &lt;Button Content="2" Width="50"&gt; &lt;Button.Triggers&gt; &lt;EventTrigger RoutedEvent="Button.Click"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="border1" Storyboard.TargetProperty="Height" To="200"/&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/Button.Triggers&gt; &lt;/Button&gt; &lt;Button Content="3" Width="50"&gt; &lt;Button.Triggers&gt; &lt;EventTrigger RoutedEvent="Button.Click"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="border1" Storyboard.TargetProperty="Height" To="300"/&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/Button.Triggers&gt; &lt;/Button&gt; &lt;/StackPanel&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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