Information Technology Consulting Service

www.katarincic.com


Welcome Guest Search | Active Topics | Members | Log In

Silverlight animation QuickStart Options · View
scott
Posted: Thursday, April 09, 2009 9:42:42 AM
Rank: Administration
Groups: Member

Joined: 3/24/2008
Posts: 2,804
Points: 5,588
Location: South Florida USA
Silverlight animation QuickStart

http://silverlight.net/quickstarts/animations.aspx

1. start a new "Silverlight Application" project in Visual Studio.

2. select "Automatically generate a test page to host Silverlight at build time"
project type: ASP .NET Web Application Project

3. add the following code to Page.xaml.vb

Code:

Partial Public Class Page
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub Animation_Begin(ByVal sender As Object, ByVal e As RoutedEventArgs)
        myStoryboard.Begin()
    End Sub

    Private Sub Animation_Pause(ByVal sender As Object, ByVal e As RoutedEventArgs)
        myStoryboard.Pause()
    End Sub

    Private Sub Animation_Resume(ByVal sender As Object, ByVal e As RoutedEventArgs)
        myStoryboard.Resume()
    End Sub

    Private Sub Animation_Stop(ByVal sender As Object, ByVal e As RoutedEventArgs)
        myStoryboard.Stop()
    End Sub

End Class


4. Add the following XAML code to Page.xaml

Code:

<UserControl x:Class="SilverlightApplication9.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <Canvas>
            <Canvas.Resources>
                <Storyboard x:Name="myStoryboard">

                    <!-- Animate the center point of the ellipse. -->
                    <PointAnimation Storyboard.TargetProperty="Center"
      Storyboard.TargetName="MyAnimatedEllipseGeometry"
      Duration="0:0:5"
      From="20,200"
      To="400,100"
      RepeatBehavior="Forever" />
                </Storyboard>
            </Canvas.Resources>

            <Path Fill="Blue">
                <Path.Data>
                    <!-- Describe an ellipse. -->
                    <EllipseGeometry x:Name="MyAnimatedEllipseGeometry"
      Center="20,20" RadiusX="15" RadiusY="15" />
                </Path.Data>
            </Path>

            <StackPanel Orientation="Horizontal" Canvas.Left="10" Canvas.Top="265">
                <!-- Button that begins animation. -->
                <Button Click="Animation_Begin"
    Width="65" Height="30" Margin="2" Content="Begin" />

                <!-- Button that pauses animation. -->
                <Button Click="Animation_Pause"
    Width="65" Height="30" Margin="2" Content="Pause" />

                <!-- Button that resumes animation. -->
                <Button Click="Animation_Resume"
    Width="65" Height="30" Margin="2" Content="Resume" />

                <!-- Button that stops animation. Stopping the animation returns the
    ellipse to its original location. -->
                <Button Click="Animation_Stop"
    Width="65" Height="30" Margin="2" Content="Stop" />
            </StackPanel>

        </Canvas>
    </Grid>
</UserControl>


5. Build/test the code

6. There are 3 files that you need to add to your Visual Studio website project:
applicationname.xap
applicationname.xml
TestPage.html

These files can be found in your project build folder, typically:
My Documents\Visual Studio 2008\Projects\{SilverlightApplication name}\{SilverlightApplication name}\Bin\Debug

7. The JavaScript and HTML from TestPage.html can be copy/pasted into your .aspx file.

8. A sample of the above code can be found here:
http://www.katarincic.com/silverlight.aspx



Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.6 (NET v2.0) - 11/14/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.038 seconds.