Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation to make height of a Rectangle to 0 in windows 8 app

In win8 app I am trying small animation to make height of Rectangle 0

Properties like Opacity are working fine, but I am not able to bring animation in height or width.

<Page.Resources>
    <Storyboard x:Name="NewStory">
        <DoubleAnimation Storyboard.TargetName="MyRectangle"  Storyboard.TargetProperty="Height" From="100" To="0" Duration="0:0:1" />
    </Storyboard>
</Page.Resources> 

<Rectangle Name="MyRectangle" Width="100" Height="100" Tapped="MyRectangle_OnTapped">

private void MyRectangle_OnTapped(object sender, TappedRoutedEventArgs e)
{
    NewStory.Begin();
}
like image 875
Shashank Bisen Avatar asked Jan 15 '23 03:01

Shashank Bisen


1 Answers

When you try to change something that influences layout then an animation for this change is called dependent animation, and it doesn't work by default. To be able to use it you should set EnableDependentAnimation property to true.

<Storyboard x:Name="NewStory">
    <DoubleAnimation Storyboard.TargetName="MyRectangle"  Storyboard.TargetProperty="Height" From="100" To="0" Duration="0:0:1" EnableDependentAnimation="true" />
</Storyboard>
like image 150
ixSci Avatar answered Feb 24 '23 03:02

ixSci