Events of StoryBoard : Storyboard « Animations « Silverlight






Events of StoryBoard

Events of StoryBoard
    


<UserControl x:Class='SilverlightApplication3.MainPage'
    xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
    xmlns:d='http://schemas.microsoft.com/expression/blend/2008' 
    xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006' 
    mc:Ignorable='d' 
    d:DesignWidth='640' d:DesignHeight='480'>
    <UserControl.Resources>
        <Storyboard x:Name="MoveRed">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="RedRectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:02" Value="520"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="MoveBlue">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BlueRectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:02" Value="20"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="MoveGreen">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="GreenRectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" BeginTime="00:00:00">
                <SplineDoubleKeyFrame KeyTime="00:00:02" Value="520"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
    <Canvas x:Name="LayoutRoot" Background="White" >
        <Rectangle Height="54" Width="149" Canvas.Left="65" Canvas.Top="58" Fill="Red" Stroke="#FF000000" RadiusY="12" RadiusX="12" x:Name="RedRectangle" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="Red_MouseUp">
            <Rectangle.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Height="54" x:Name="BlueRectangle" Width="149" RadiusX="12" RadiusY="12" Fill="#FF0050FF" Stroke="#FF000000" Canvas.Left="65" Canvas.Top="133" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="Blue_MouseUp">
            <Rectangle.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Height="54" x:Name="GreenRectangle" Width="149" RadiusX="12" RadiusY="12" Fill="Blue" Stroke="#FF000000" Canvas.Left="65" Canvas.Top="207" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="Green_MouseUp">
            <Rectangle.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Rectangle.RenderTransform>
        </Rectangle>
    </Canvas>
</UserControl>


//File: Page.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverlightApplication3
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Red_MouseUp(object sender, MouseButtonEventArgs e)
        {
            MoveRed.Begin();
        }

        private void Blue_MouseUp(object sender, MouseButtonEventArgs e)
        {
            MoveBlue.Begin();
        }

        private void Green_MouseUp(object sender, MouseButtonEventArgs e)
        {
            MoveGreen.Begin();
        }
    }
}

   
    
    
    
  








Related examples in the same category

1.Rectangle Trigger and StoryboardRectangle Trigger and Storyboard
2.Storyboard EventsStoryboard Events
3.Storyboard PropertiesStoryboard Properties
4.Storyboard as ResourceStoryboard as Resource
5.Use two storyboards to control the slidein and slideoutUse two storyboards to control the slidein and slideout
6.Defining a Storyboard as a resource
7.Starting a Storyboard from code-behind
8.Syntax of Storyboard element with multiple animations
9.Animation overriding target of its parent StoryboardAnimation overriding target of its parent Storyboard
10.Start a story board with code
11.An animation that uses the playback methods and the Completed event
12.Pausing and resuming a storyboard with triggers