Thursday, September 18, 2008

How to animate a Line WPF


Private Sub AnimateLine(ByVal myLine As Line, ByVal p1 As Windows.Point, ByVal p2 As Windows.Point)
        Dim daX As DoubleAnimation = New DoubleAnimation(p1.X, p2.X, New Windows.Duration(TimeSpan.FromSeconds(3)))
        daX.RepeatBehavior = RepeatBehavior.Forever
        daX.AutoReverse = True
        myLine.BeginAnimation(Line.X2Property, daX)

        Dim daY As DoubleAnimation = New DoubleAnimation(p1.Y, p2.Y, New Windows.Duration(TimeSpan.FromSeconds(3)))
        daY.RepeatBehavior = RepeatBehavior.Forever
        daY.AutoReverse = True
        myLine.BeginAnimation(Line.Y2Property, daY)
    End Sub

'Enjoy IT!

Tuesday, September 16, 2008

Simplest way to Animate a Control in WPF


This may be the simplest way to animate a dependency property in WPF

Button1.BeginAnimation(Button.HeightProperty, New DoubleAnimation(25, 150, New Duration(New TimeSpan(0, 0, 1))))


Enjoy IT!