Bagikan melalui


Collapsing animation in WPF

its been some time since my last post.. so to get things going heres some simple animation code which collapses objects and the one above takes its place (something on the lines of tetrix :) ) .. the main part of this code is a small snippet which I came across some time ago (written by Bob Shogren)

            <EventTrigger RoutedEvent="Mouse.PreviewMouseDown">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation
                                Storyboard.TargetProperty = "Opacity"
                                To                          = "0"
                                BeginTime                   = "0:0:0"
                                Duration                    = "0:0:2" />
                             <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetProperty = "Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0:0:2"   Value="{x:Static Visibility.Collapsed}" />
                             </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>

This gives a nice collapsing effect when you click on a block. Give it a try. :). Code is attached.

collapse.xaml