PageRenderTime 33ms CodeModel.GetById 24ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/Visual Studio 2008/VBSL3Animation/CodeBehindCreation.xaml.vb

#
Visual Basic | 50 lines | 17 code | 7 blank | 26 comment | 0 complexity | fd8ffc080129c587d7f10a18ca027f7d MD5 | raw file
 1'***************************** Module Header ******************************\
 2'* Module Name:  CodeBehindCreation.xaml.vb
 3'* Project:      VBSL3Animation
 4'* Copyright (c) Microsoft Corporation.
 5'* 
 6'* This module shows how to initialize a Storyboard in code behind. The final effect
 7'* is the same as BasicPointAnimation.xaml, which uses XAML to add Storyboard.
 8'* 
 9'* This source is subject to the Microsoft Public License.
10'* See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11'* All other rights reserved.
12'* 
13'* History:
14'* * 9/10/2009 03:00 PM Allen Chen Created
15'\**************************************************************************
16
17Partial Public Class CodeBehindCreation
18    Inherits UserControl
19
20    Private _myAnimation As PointAnimation = New PointAnimation()
21    Private _myAnimationStoryboard As Storyboard = New Storyboard()
22
23    ''' <summary>
24    ''' In the following constructor, the PointAnimation is added to Storyboard.
25    ''' They are initialized for animation.
26    ''' </summary>
27    Public Sub New()
28        InitializeComponent()
29        _myAnimation.Duration = New Duration(TimeSpan.FromSeconds(2))
30        _myAnimation.SetValue(Storyboard.TargetPropertyProperty, New PropertyPath("Center"))
31        Storyboard.SetTarget(_myAnimation, MyAnimatedEllipseGeometry)
32        _myAnimationStoryboard.Children.Add(_myAnimation)
33    End Sub
34
35    ''' <summary>
36    ''' Tbe following event handler change the To property of PointAnimation object,
37    ''' then begin the Storyboard to play the animation. Please note we can change
38    ''' To property even when the animation is playing.
39    ''' </summary>
40    ''' <param name="sender"></param>
41    ''' <param name="e"></param>
42    Private Sub MyStackPanel_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
43
44        Dim targetpoint = e.GetPosition(Me.MyStackPanel)
45        Me._myAnimation.To = targetpoint
46        Me._myAnimationStoryboard.Begin()
47
48    End Sub
49
50End Class