A Simple Animation in Code : Animation « Windows Presentation Foundation « VB.Net






A Simple Animation in Code

A Simple Animation in Code
    

<Window x:Class="WpfApplication1.SimpleAnimation" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="Simple Animation Example" Height="300" Width="300"> 
    <Canvas>
        <Rectangle x:Name="rect1" Width="100" Height="50" Fill="Blue"/> 
    </Canvas> 
</Window> 
//File:Window.xaml.vb

Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Imports System.Windows.Shapes
Imports System.Windows.Media.Animation


Namespace WpfApplication1
  Public Partial Class SimpleAnimation
    Inherits Window
    Public Sub New()
      InitializeComponent()
      Dim da As New DoubleAnimation()
      da.From = 0
      da.[To] = 200
      da.Duration = TimeSpan.FromSeconds(5)
      da.AutoReverse = True
      da.RepeatBehavior = RepeatBehavior.Forever
      rect1.BeginAnimation(Canvas.LeftProperty, da)
      rect1.BeginAnimation(Canvas.TopProperty, da)
    End Sub
  End Class
End Namespace

   
    
    
    
  








Related examples in the same category

1.Animated StartPointAnimated StartPoint
2.Animated EndPointAnimated EndPoint
3.Animated StartPoint and EndPointAnimated StartPoint and EndPoint
4.Animated GradientStop Offset with DoubleAnimationAnimated GradientStop Offset with DoubleAnimation
5.Animated GradientStop Color with ColorAnimationAnimated GradientStop Color with ColorAnimation
6.Animated GradientStop Opacity ColorAnimation.ByAnimated GradientStop Opacity ColorAnimation.By
7.Animated GradientOriginAnimated GradientOrigin
8.Animated CenterAnimated Center
9.Animated RadiusAnimated Radius
10.Animating ColorAnimating Color
11.Animating Gradient OffsetAnimating Gradient Offset
12.Animate GradientStopAnimate GradientStop
13.Simple Key Frame AnimationSimple Key Frame Animation
14.KeyFrame Point AnimationKeyFrame Point Animation
15.Use Button to pause an animation with PauseStoryboardUse Button to pause an animation with PauseStoryboard
16.Use Button to resume an Animation with ResumeStoryboardUse Button to resume an Animation with ResumeStoryboard
17.Use Button to skip an Animation with SkipStoryboardToFillUse Button to skip an Animation with SkipStoryboardToFill
18.Use Button to stop an Animation with StopStoryboardUse Button to stop an Animation with StopStoryboard
19.Frame RatesFrame Rates
20.Using PointAnimationUsing PointAnimation
21.PointAnimation and BezierSegmentPointAnimation and BezierSegment
22.PointAnimation ToPointAnimation To
23.Animate BezierCurveAnimate BezierCurve
24.Animation of the combined transformAnimation of the combined transform
25.Animate the Opacity of TextBlock at different starting timeAnimate the Opacity of TextBlock at different starting time
26.Animate Canvas positionAnimate Canvas position
27.RepeatBehavior=2xRepeatBehavior=2x
28.Use DiscreteDoubleKeyFrame to switch textUse DiscreteDoubleKeyFrame to switch text
29.Paced AnimationPaced Animation
30.Xaml ClockXaml Clock
31.Enlarge Buttons In XamlEnlarge Buttons In Xaml
32.Use SplineDoubleKeyFrame to rotate a ButtonUse SplineDoubleKeyFrame to rotate a Button
33.Key frame animationKey frame animation
34.Key frame spline animationKey frame spline animation
35.Setting enumeration values with discrete animations with DiscreteObjectKeyFrameSetting enumeration values with discrete animations with DiscreteObjectKeyFrame
36.Point path animationPoint path animation
37.String Animation Using Key FramesString Animation Using Key Frames
38.Expand ElementExpand Element
39.Animating nested propertiesAnimating nested properties
40.Animation LinearGradientBrushAnimation LinearGradientBrush
41.Use ColorAnimation to animate backgroundUse ColorAnimation to animate background
42.Text AnimationText Animation
43.Start and stop an Animation with Button actionsStart and stop an Animation with Button actions
44.Animate TransformationAnimate Transformation
45.Associating the clicking of each button with a stack of XAML that starts or stops the animationAssociating the clicking of each button with a stack of XAML that starts or stops the animation
46.Limit the Frame Rate for All Animations in an ApplicationLimit the Frame Rate for All Animations in an Application
47.Animated Button With Discrete Key FramesAnimated Button With Discrete Key Frames
48.Animation In XamlAnimation In Xaml
49.Using SpeedRatio in a hierarchyUsing SpeedRatio in a hierarchy
50.SplineDoubleKeyFrame and KeySplineSplineDoubleKeyFrame and KeySpline
51.Hold on end for an AnimationHold on end for an Animation
52.Animate Several PropertiesAnimate Several Properties
53.Scaling parameters ScaleX and ScaleY are animatedScaling parameters ScaleX and ScaleY are animated
54.Animation ProgressBar.Animation ProgressBar.
55.Control the Progress of an AnimationControl the Progress of an Animation
56.Remove Animations with AnimationClockRemove Animations with AnimationClock
57.Remove AnimationsRemove Animations
58.Timer triggered AnimationTimer triggered Animation
59.Path animation by code, duration, RepeatBehaviorPath animation by code, duration, RepeatBehavior
60.Rolling Ball AnimationRolling Ball Animation
61.Create an interactive animation using XAML and the StoryboardCreate an interactive animation using XAML and the Storyboard
62.Create animations using the Storyboard in codeCreate animations using the Storyboard in code
63.Receive Notification When an Animation CompletesReceive Notification When an Animation Completes
64.Create DoubleAnimation and Animate a Button with Button.BeginAnimation and Button.WidthPropertyCreate DoubleAnimation and Animate a Button with Button.BeginAnimation and Button.WidthProperty
65.Velocity animationVelocity animation
66.A simple, finite animationA simple, finite animation
67.Code Animation Accelerate DecelerateCode Animation Accelerate Decelerate
68.Animation with codeAnimation with code
69.Opacity Animation
70.Width and Height animation
71.TranslateTransform and DoubleAnimation
72.Rotate Button AnimationRotate Button Animation
73.Rotate Button Animation With LayoutRotate Button Animation With Layout
74.Stop, resume animation with StoryboardStop, resume animation with Storyboard