แชร์ผ่าน


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

Comments

  • Anonymous
    October 03, 2006
    The attachment doesn't appear to be there anymore :(

  • Anonymous
    October 30, 2006
    The file does exist... right click on the collapse.xaml link and save it as a xaml file.... if you have .NET installed and click on the link it opens it up in the browser..so u dont see the xaml :)