Storyboard.Begin 메서드

정의

Storyboard와 연결된 애니메이션 집합을 시작합니다.Initiates the set of animations associated with this Storyboard.

오버로드

Begin(FrameworkElement, FrameworkTemplate, HandoffBehavior, Boolean)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

Begin(FrameworkElement, HandoffBehavior, Boolean)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

Begin(FrameworkElement, FrameworkTemplate, HandoffBehavior)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

Begin(FrameworkElement, FrameworkTemplate, Boolean)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

Begin(FrameworkContentElement, HandoffBehavior, Boolean)

지정된 Storyboard를 통해 이 HandoffBehavior와 연결된 애니메이션을 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them, using the specified HandoffBehavior.

Begin(FrameworkElement, FrameworkTemplate)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

Begin(FrameworkElement, HandoffBehavior)

지정된 Storyboard를 통해 이 HandoffBehavior와 연결된 애니메이션을 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them, using the specified HandoffBehavior.

Begin(FrameworkContentElement, HandoffBehavior)

지정된 Storyboard를 통해 이 HandoffBehavior와 연결된 애니메이션을 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them, using the specified HandoffBehavior.

Begin(FrameworkContentElement, Boolean)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

Begin(FrameworkElement)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

Begin(FrameworkContentElement)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

Begin()

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

Begin(FrameworkElement, Boolean)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

설명

제어 가능한 storyboard 수 일시 중지, 다시 시작, 검색, 중지 및 제거할 수 있습니다.A controllable storyboard can pause, resume, seek, stop, and be removed. 스토리 보드를 코드에서 제어할 수 있도록 해당 스토리 보드의 오버 로드를 사용 해야 합니다 Begin 메서드를 지정 하 고 true 제어할 수 있도록 합니다.To make a storyboard controllable in code, you must use the appropriate overload of the storyboard's Begin method and specify true to make it controllable. 예를 들어 참조 방법:는 Storyboard를 시작한 후 제어입니다.For an example, see How to: Control a Storyboard After It Starts.

Begin(FrameworkElement, FrameworkTemplate, HandoffBehavior, Boolean)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject, System::Windows::FrameworkTemplate ^ frameworkTemplate, System::Windows::Media::Animation::HandoffBehavior handoffBehavior, bool isControllable);
public void Begin (System.Windows.FrameworkElement containingObject, System.Windows.FrameworkTemplate frameworkTemplate, System.Windows.Media.Animation.HandoffBehavior handoffBehavior, bool isControllable);
member this.Begin : System.Windows.FrameworkElement * System.Windows.FrameworkTemplate * System.Windows.Media.Animation.HandoffBehavior * bool -> unit

매개 변수

containingObject
FrameworkElement

지정된 frameworkTemplate을 적용한 개체입니다.The object to which the specified frameworkTemplate has been applied. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

frameworkTemplate
FrameworkTemplate

애니메이션을 적용할 템플릿입니다.The template to animate.

handoffBehavior
HandoffBehavior

새 애니메이션이 현재 애니메이션과 상호 작용하기 위해 사용할 동작입니다.The behavior the new animation should use to interact with any current animations.

isControllable
Boolean

스토리보드를 대화형으로 제어할 수 있어야 하는 경우 true이고, 그러지 않으면 false입니다.true if the storyboard should be interactively controllable; otherwise, false.

설명

이 스토리 보드를 대화형으로 제어 하려면 지정 해야 동일한 containingObject 시작 스토리 보드를 사용 하는 대화형 메서드를 호출 하는 경우To interactively control this storyboard, you must specify the same containingObject when calling the interactive methods that you used to begin the storyboard

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

사용 하 여 Compose HandoffBehaviorUsing the Compose HandoffBehavior

적용 하는 경우는 Storyboard, AnimationTimeline, 또는 AnimationClock 사용 하 여 속성을 Compose HandoffBehavior모든 Clock 개체 속성과 연관 된 이전에 시스템 리소스를 소비 계속; 타이밍 시스템 하지 않습니다 자동으로 이러한 클록을 제거 합니다.When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove these clocks automatically.

많은 수의 시계를 사용 하 여 적용 하는 경우 성능 문제를 방지 하려면 Compose를 완성 한 후 애니메이션된 속성에서 구성 중인 클록을 제거 해야 합니다.To avoid performance issues when you apply a large number of clocks using Compose, you should remove composing clocks from the animated property after they complete. 여러 가지 방법으로 클록을 제거할 수 있습니다.There are several ways to remove a clock.

이것은 주로 수명이 긴 개체에 대한 애니메이션에서 문제가 됩니다.This is primarily an issue for animations on objects that have a long lifetime. 개체는 가비지 수집 되 면 해당 클록도 연결이 끊어집니다 및 가비지 수집 합니다.When an object is garbage collected, its clocks are also disconnected and garbage collected.

클록 개체에 대 한 자세한 내용은 참조 하세요. 애니메이션 및 타이밍 시스템 개요합니다.For more information about clock objects, see Animation and Timing System Overview.

Begin(FrameworkElement, HandoffBehavior, Boolean)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject, System::Windows::Media::Animation::HandoffBehavior handoffBehavior, bool isControllable);
public void Begin (System.Windows.FrameworkElement containingObject, System.Windows.Media.Animation.HandoffBehavior handoffBehavior, bool isControllable);
member this.Begin : System.Windows.FrameworkElement * System.Windows.Media.Animation.HandoffBehavior * bool -> unit

매개 변수

containingObject
FrameworkElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. 지정된 TargetName이 없는 애니메이션은 containingObject에 적용됩니다.Animations without a specified TargetName are applied to containingObject.

handoffBehavior
HandoffBehavior

새 애니메이션이 현재 애니메이션과 상호 작용하기 위해 사용할 동작입니다.The behavior the new animation should use to interact with any current animations.

isControllable
Boolean

애니메이션을 시작한 후 제어(일시 중지)할 수 있는지 여부를 선언합니다.Declares whether the animation is controllable (can be paused) once started.

예제

다음 예제에는 제어 가능한 storyboard를 만드는 방법을 보여 줍니다.The following example shows how to create a controllable storyboard.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace SDKSample
{

    public class ControllableStoryboardExample : Page
    {
        private Storyboard myStoryboard;

        public ControllableStoryboardExample()
        {

            // Create a name scope for the page.

            NameScope.SetNameScope(this, new NameScope()); 
 
            this.WindowTitle = "Controllable Storyboard Example";
            StackPanel myStackPanel = new StackPanel();
            myStackPanel.Margin = new Thickness(10);

            // Create a rectangle.
            Rectangle myRectangle = new Rectangle();
            myRectangle.Name = "myRectangle";

            // Assign the rectangle a name by 
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations.
            this.RegisterName(myRectangle.Name, myRectangle);
            myRectangle.Width = 100;
            myRectangle.Height = 100;
            myRectangle.Fill = Brushes.Blue;
            myStackPanel.Children.Add(myRectangle);

            //
            // Create an animation and a storyboard to animate the
            // rectangle.
            //
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 1.0;
            myDoubleAnimation.To = 0.0;
            myDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(5000));
            myDoubleAnimation.AutoReverse = true;

            // Create the storyboard.
            myStoryboard = new Storyboard();
            myStoryboard.Children.Add(myDoubleAnimation);
            Storyboard.SetTargetName(myDoubleAnimation, myRectangle.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.OpacityProperty));

            //
            // Create some buttons to control the storyboard
            // and a panel to contain them.
            //
            StackPanel buttonPanel = new StackPanel();
            buttonPanel.Orientation = Orientation.Horizontal;
            Button beginButton = new Button();
            beginButton.Content = "Begin";
            beginButton.Click += new RoutedEventHandler(beginButton_Clicked);
            buttonPanel.Children.Add(beginButton);
            Button pauseButton = new Button();
            pauseButton.Content = "Pause";
            pauseButton.Click += new RoutedEventHandler(pauseButton_Clicked);
            buttonPanel.Children.Add(pauseButton);
            Button resumeButton = new Button();
            resumeButton.Content = "Resume";
            resumeButton.Click += new RoutedEventHandler(resumeButton_Clicked);
            buttonPanel.Children.Add(resumeButton);
            Button skipToFillButton = new Button();
            skipToFillButton.Content = "Skip to Fill";
            skipToFillButton.Click += new RoutedEventHandler(skipToFillButton_Clicked);
            buttonPanel.Children.Add(skipToFillButton);
            Button setSpeedRatioButton = new Button();
            setSpeedRatioButton.Content = "Triple Speed";
            setSpeedRatioButton.Click += new RoutedEventHandler(setSpeedRatioButton_Clicked);
            buttonPanel.Children.Add(setSpeedRatioButton);
            Button stopButton = new Button();
            stopButton.Content = "Stop";
            stopButton.Click += new RoutedEventHandler(stopButton_Clicked);
            buttonPanel.Children.Add(stopButton);
            myStackPanel.Children.Add(buttonPanel);
            this.Content = myStackPanel;        
            

        }

        // Begins the storyboard.
        private void beginButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Specifying "true" as the second Begin parameter
            // makes this storyboard controllable.
            myStoryboard.Begin(this, true);

        }

        // Pauses the storyboard.
        private void pauseButton_Clicked(object sender, RoutedEventArgs args)
        {
            myStoryboard.Pause(this);

        }

        // Resumes the storyboard.
        private void resumeButton_Clicked(object sender, RoutedEventArgs args)
        {
            myStoryboard.Resume(this);

        }

        // Advances the storyboard to its fill period.
        private void skipToFillButton_Clicked(object sender, RoutedEventArgs args)
        {
            myStoryboard.SkipToFill(this);

        }

        // Updates the storyboard's speed.
        private void setSpeedRatioButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Makes the storyboard progress three times as fast as normal.
            myStoryboard.SetSpeedRatio(this, 3);

        }

        // Stops the storyboard.
        private void stopButton_Clicked(object sender, RoutedEventArgs args)
        {
            myStoryboard.Stop(this);

        }         

    }

}

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

Namespace SDKSample

    Public Class ControllableStoryboardExample
        Inherits Page
        Private myStoryboard As Storyboard

        Public Sub New()

            ' Create a name scope for the page.

            NameScope.SetNameScope(Me, New NameScope())

            Me.WindowTitle = "Controllable Storyboard Example"
            Dim myStackPanel As New StackPanel()
            myStackPanel.Margin = New Thickness(10)

            ' Create a rectangle.
            Dim myRectangle As New Rectangle()
            myRectangle.Name = "myRectangle"

            ' Assign the rectangle a name by 
            ' registering it with the page, so that
            ' it can be targeted by storyboard
            ' animations.
            Me.RegisterName(myRectangle.Name, myRectangle)
            myRectangle.Width = 100
            myRectangle.Height = 100
            myRectangle.Fill = Brushes.Blue
            myStackPanel.Children.Add(myRectangle)

            '
            ' Create an animation and a storyboard to animate the
            ' rectangle.
            '
            Dim myDoubleAnimation As New DoubleAnimation()
            myDoubleAnimation.From = 1.0
            myDoubleAnimation.To = 0.0
            myDoubleAnimation.Duration = New Duration(TimeSpan.FromMilliseconds(5000))
            myDoubleAnimation.AutoReverse = True

            ' Create the storyboard.
            myStoryboard = New Storyboard()
            myStoryboard.Children.Add(myDoubleAnimation)
            Storyboard.SetTargetName(myDoubleAnimation, myRectangle.Name)
            Storyboard.SetTargetProperty(myDoubleAnimation, New PropertyPath(Rectangle.OpacityProperty))

            '
            ' Create some buttons to control the storyboard
            ' and a panel to contain them.
            '
            Dim buttonPanel As New StackPanel()
            buttonPanel.Orientation = Orientation.Horizontal
            Dim beginButton As New Button()
            beginButton.Content = "Begin"
            AddHandler beginButton.Click, AddressOf beginButton_Clicked
            buttonPanel.Children.Add(beginButton)
            Dim pauseButton As New Button()
            pauseButton.Content = "Pause"
            AddHandler pauseButton.Click, AddressOf pauseButton_Clicked
            buttonPanel.Children.Add(pauseButton)
            Dim resumeButton As New Button()
            resumeButton.Content = "Resume"
            AddHandler resumeButton.Click, AddressOf resumeButton_Clicked
            buttonPanel.Children.Add(resumeButton)
            Dim skipToFillButton As New Button()
            skipToFillButton.Content = "Skip to Fill"
            AddHandler skipToFillButton.Click, AddressOf skipToFillButton_Clicked
            buttonPanel.Children.Add(skipToFillButton)
            Dim setSpeedRatioButton As New Button()
            setSpeedRatioButton.Content = "Triple Speed"
            AddHandler setSpeedRatioButton.Click, AddressOf setSpeedRatioButton_Clicked
            buttonPanel.Children.Add(setSpeedRatioButton)
            Dim stopButton As New Button()
            stopButton.Content = "Stop"
            AddHandler stopButton.Click, AddressOf stopButton_Clicked
            buttonPanel.Children.Add(stopButton)
            myStackPanel.Children.Add(buttonPanel)
            Me.Content = myStackPanel


        End Sub

        ' Begins the storyboard.
        Private Sub beginButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            ' Specifying "true" as the second Begin parameter
            ' makes this storyboard controllable.
            myStoryboard.Begin(Me, True)

        End Sub

        ' Pauses the storyboard.
        Private Sub pauseButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            myStoryboard.Pause(Me)

        End Sub

        ' Resumes the storyboard.
        Private Sub resumeButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            myStoryboard.Resume(Me)

        End Sub

        ' Advances the storyboard to its fill period.
        Private Sub skipToFillButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            myStoryboard.SkipToFill(Me)

        End Sub

        ' Updates the storyboard's speed.
        Private Sub setSpeedRatioButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            ' Makes the storyboard progress three times as fast as normal.
            myStoryboard.SetSpeedRatio(Me, 3)

        End Sub

        ' Stops the storyboard.
        Private Sub stopButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            myStoryboard.Stop(Me)

        End Sub

    End Class

End Namespace

다음 예제에서는 합니다 SnapshotAndReplace HandoffBehavior 사용자가, 및 Compose HandoffBehavior 클릭할 때입니다.The next example uses the SnapshotAndReplace HandoffBehavior to animate when the user left-clicks, and the Compose HandoffBehavior when the user right-clicks.

/*

   This sample animates the position of an ellipse when 
   the user clicks within the main border. If the user
   left-clicks, the SnapshotAndReplace HandoffBehavior
   is used when applying the animations. If the user
   right-clicks, the Compose HandoffBehavior is used
   instead.

*/

using System;
using System.Windows;
using System.Windows.Navigation;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Input;

namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
{

    // Create the demonstration.
    public class FrameworkElementStoryboardHandoffBehaviorExample : Page {
        
        
        private Border containerBorder;
        private Ellipse interactiveEllipse;
        private Storyboard theStoryboard;
        private DoubleAnimation xAnimation;
        private DoubleAnimation yAnimation;
        
        public FrameworkElementStoryboardHandoffBehaviorExample()
        {
        
            WindowTitle = "Interactive Animation Example";
            
            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());  
            
            DockPanel myPanel = new DockPanel();
            myPanel.Margin = new Thickness(20.0);            
    
            containerBorder = new Border();
            containerBorder.Background = Brushes.White;
            containerBorder.BorderBrush = Brushes.Black;
            containerBorder.BorderThickness = new Thickness(2.0); 
            containerBorder.VerticalAlignment = VerticalAlignment.Stretch;
            
            interactiveEllipse = new Ellipse();
            interactiveEllipse.Fill = Brushes.Lime;
            interactiveEllipse.Stroke = Brushes.Black;
            interactiveEllipse.StrokeThickness = 2.0;
            interactiveEllipse.Width = 25;
            interactiveEllipse.Height = 25;
            interactiveEllipse.HorizontalAlignment = HorizontalAlignment.Left;
            interactiveEllipse.VerticalAlignment = VerticalAlignment.Top;
            

            TranslateTransform interactiveTranslateTransform = new TranslateTransform();       
            this.RegisterName("InteractiveTranslateTransform", interactiveTranslateTransform);
            
            interactiveEllipse.RenderTransform = 
                interactiveTranslateTransform;
                
            xAnimation = new DoubleAnimation();
            xAnimation.Duration = TimeSpan.FromSeconds(4);
            yAnimation = xAnimation.Clone();
            Storyboard.SetTargetName(xAnimation, "InteractiveTranslateTransform");
            Storyboard.SetTargetProperty(xAnimation, new PropertyPath(TranslateTransform.XProperty));
            Storyboard.SetTargetName(yAnimation, "InteractiveTranslateTransform");
            Storyboard.SetTargetProperty(yAnimation, new PropertyPath(TranslateTransform.YProperty));            
            
            theStoryboard = new Storyboard();
            theStoryboard.Children.Add(xAnimation);
            theStoryboard.Children.Add(yAnimation);
                
                
            containerBorder.MouseLeftButtonDown += 
                new MouseButtonEventHandler(border_mouseLeftButtonDown);
            containerBorder.MouseRightButtonDown += 
                new MouseButtonEventHandler(border_mouseRightButtonDown);                
            
            containerBorder.Child = interactiveEllipse;
            myPanel.Children.Add(containerBorder);
            this.Content = myPanel;
        }
        

        // When the user left-clicks, use the 
        // SnapshotAndReplace HandoffBehavior when applying the animation.        
        private void border_mouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
        
            Point clickPoint = Mouse.GetPosition(containerBorder);
            
            // Set the target point so the center of the ellipse
            // ends up at the clicked point.
            Point targetPoint = new Point();
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2;
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2;  
            
            // Animate to the target point.
            xAnimation.To = targetPoint.X;
            yAnimation.To = targetPoint.Y;
            theStoryboard.Begin(this, HandoffBehavior.SnapshotAndReplace);
            

            // Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Lime;
                    
        }
        
        // When the user right-clicks, use the 
        // Compose HandoffBehavior when applying the animation.
        private void border_mouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
        
            // Find the point where the use clicked.
            Point clickPoint = Mouse.GetPosition(containerBorder);
            
            // Set the target point so the center of the ellipse
            // ends up at the clicked point.
            Point targetPoint = new Point();
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2;
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2;
 
            // Animate to the target point.
            xAnimation.To = targetPoint.X;
            yAnimation.To = targetPoint.Y;
            theStoryboard.Begin(this, HandoffBehavior.Compose);
                
            // Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Orange;
            
                    
        }
        
    }
 
}
'
'
'   This sample animates the position of an ellipse when 
'   the user clicks within the main border. If the user
'   left-clicks, the SnapshotAndReplace HandoffBehavior
'   is used when applying the animations. If the user
'   right-clicks, the Compose HandoffBehavior is used
'   instead.
'
'


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

Namespace Microsoft.Samples.Animation.AnimatingWithStoryboards

    ' Create the demonstration.
    Public Class FrameworkElementStoryboardHandoffBehaviorExample
        Inherits Page


        Private containerBorder As Border
        Private interactiveEllipse As Ellipse
        Private theStoryboard As Storyboard
        Private xAnimation As DoubleAnimation
        Private yAnimation As DoubleAnimation

        Public Sub New()

            WindowTitle = "Interactive Animation Example"

            ' Create a name scope for the page.
            NameScope.SetNameScope(Me, New NameScope())

            Dim myPanel As New DockPanel()
            myPanel.Margin = New Thickness(20.0)

            containerBorder = New Border()
            containerBorder.Background = Brushes.White
            containerBorder.BorderBrush = Brushes.Black
            containerBorder.BorderThickness = New Thickness(2.0)
            containerBorder.VerticalAlignment = VerticalAlignment.Stretch

            interactiveEllipse = New Ellipse()
            With interactiveEllipse
                .Fill = Brushes.Lime
                .Stroke = Brushes.Black
                .StrokeThickness = 2.0
                .Width = 25
                .Height = 25
                .HorizontalAlignment = HorizontalAlignment.Left
                .VerticalAlignment = VerticalAlignment.Top
            End With

            Dim interactiveTranslateTransform As New TranslateTransform()
            Me.RegisterName("InteractiveTranslateTransform", interactiveTranslateTransform)

            interactiveEllipse.RenderTransform = interactiveTranslateTransform

            xAnimation = New DoubleAnimation()
            xAnimation.Duration = TimeSpan.FromSeconds(4)
            yAnimation = xAnimation.Clone()
            Storyboard.SetTargetName(xAnimation, "InteractiveTranslateTransform")
            Storyboard.SetTargetProperty(xAnimation, New PropertyPath(TranslateTransform.XProperty))
            Storyboard.SetTargetName(yAnimation, "InteractiveTranslateTransform")
            Storyboard.SetTargetProperty(yAnimation, New PropertyPath(TranslateTransform.YProperty))

            theStoryboard = New Storyboard()
            theStoryboard.Children.Add(xAnimation)
            theStoryboard.Children.Add(yAnimation)


            AddHandler containerBorder.MouseLeftButtonDown, AddressOf border_mouseLeftButtonDown
            AddHandler containerBorder.MouseRightButtonDown, AddressOf border_mouseRightButtonDown

            containerBorder.Child = interactiveEllipse
            myPanel.Children.Add(containerBorder)
            Me.Content = myPanel
        End Sub


        ' When the user left-clicks, use the 
        ' SnapshotAndReplace HandoffBehavior when applying the animation.        
        Private Sub border_mouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

            Dim clickPoint As Point = Mouse.GetPosition(containerBorder)

            ' Set the target point so the center of the ellipse
            ' ends up at the clicked point.
            Dim targetPoint As New Point()
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2

            ' Animate to the target point.
            xAnimation.To = targetPoint.X
            yAnimation.To = targetPoint.Y
            theStoryboard.Begin(Me, HandoffBehavior.SnapshotAndReplace)


            ' Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Lime

        End Sub

        ' When the user right-clicks, use the 
        ' Compose HandoffBehavior when applying the animation.
        Private Sub border_mouseRightButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

            ' Find the point where the use clicked.
            Dim clickPoint As Point = Mouse.GetPosition(containerBorder)

            ' Set the target point so the center of the ellipse
            ' ends up at the clicked point.
            Dim targetPoint As New Point()
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2

            ' Animate to the target point.
            xAnimation.To = targetPoint.X
            yAnimation.To = targetPoint.Y
            theStoryboard.Begin(Me, HandoffBehavior.Compose)

            ' Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Orange


        End Sub

    End Class

End Namespace

설명

이 스토리 보드를 대화형으로 제어 하려면 사용 해야 동일한 containingObject 스토리 보드를 시작 하는 데는 대화형 메서드를 호출할 때 매개 변수To interactively control this storyboard, you must use the same containingObject parameter when calling the interactive methods that you used to begin the storyboard

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

사용 하 여 Compose HandoffBehaviorUsing the Compose HandoffBehavior

적용 하는 경우는 Storyboard, AnimationTimeline, 또는 AnimationClock 사용 하 여 속성을 Compose HandoffBehavior모든 Clock 개체 속성과 연관 된 이전에 시스템 리소스를 소비 계속; 타이밍 시스템 하지 않습니다 자동으로 이러한 클록을 제거 합니다.When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove these clocks automatically.

많은 수의 시계를 사용 하 여 적용 하는 경우 성능 문제를 방지 하려면 Compose를 완성 한 후 애니메이션된 속성에서 구성 중인 클록을 제거 해야 합니다.To avoid performance issues when you apply a large number of clocks using Compose, you should remove composing clocks from the animated property after they complete. 여러 가지 방법으로 클록을 제거할 수 있습니다.There are several ways to remove a clock.

이것은 주로 수명이 긴 개체에 대한 애니메이션에서 문제가 됩니다.This is primarily an issue for animations on objects that have a long lifetime. 개체는 가비지 수집 되 면 해당 클록도 연결이 끊어집니다 및 가비지 수집 합니다.When an object is garbage collected, its clocks are also disconnected and garbage collected.

클록 개체에 대 한 자세한 내용은 참조 하세요. 애니메이션 및 타이밍 시스템 개요합니다.For more information about clock objects, see Animation and Timing System Overview.

Begin(FrameworkElement, FrameworkTemplate, HandoffBehavior)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject, System::Windows::FrameworkTemplate ^ frameworkTemplate, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void Begin (System.Windows.FrameworkElement containingObject, System.Windows.FrameworkTemplate frameworkTemplate, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
member this.Begin : System.Windows.FrameworkElement * System.Windows.FrameworkTemplate * System.Windows.Media.Animation.HandoffBehavior -> unit

매개 변수

containingObject
FrameworkElement

지정된 frameworkTemplate을 적용한 개체입니다.The object to which the specified frameworkTemplate has been applied. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

frameworkTemplate
FrameworkTemplate

애니메이션을 적용할 템플릿입니다.The template to animate.

handoffBehavior
HandoffBehavior

새 애니메이션이 현재 애니메이션과 상호 작용하기 위해 사용할 동작입니다.The behavior the new animation should use to interact with any current animations.

설명

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

사용 하 여 Compose HandoffBehaviorUsing the Compose HandoffBehavior

적용 하는 경우는 Storyboard, AnimationTimeline, 또는 AnimationClock 사용 하 여 속성을 Compose HandoffBehavior모든 Clock 개체 속성과 연관 된 이전에 시스템 리소스를 소비 계속; 타이밍 시스템 하지 않습니다 자동으로 이러한 클록을 제거 합니다.When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove these clocks automatically.

많은 수의 시계를 사용 하 여 적용 하는 경우 성능 문제를 방지 하려면 Compose를 완성 한 후 애니메이션된 속성에서 구성 중인 클록을 제거 해야 합니다.To avoid performance issues when you apply a large number of clocks using Compose, you should remove composing clocks from the animated property after they complete. 여러 가지 방법으로 클록을 제거할 수 있습니다.There are several ways to remove a clock.

이것은 주로 수명이 긴 개체에 대한 애니메이션에서 문제가 됩니다.This is primarily an issue for animations on objects that have a long lifetime. 개체는 가비지 수집 되 면 해당 클록도 연결이 끊어집니다 및 가비지 수집 합니다.When an object is garbage collected, its clocks are also disconnected and garbage collected.

클록 개체에 대 한 자세한 내용은 참조 하세요. 애니메이션 및 타이밍 시스템 개요합니다.For more information about clock objects, see Animation and Timing System Overview.

Begin(FrameworkElement, FrameworkTemplate, Boolean)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject, System::Windows::FrameworkTemplate ^ frameworkTemplate, bool isControllable);
public void Begin (System.Windows.FrameworkElement containingObject, System.Windows.FrameworkTemplate frameworkTemplate, bool isControllable);
member this.Begin : System.Windows.FrameworkElement * System.Windows.FrameworkTemplate * bool -> unit

매개 변수

containingObject
FrameworkElement

지정된 frameworkTemplate을 적용한 개체입니다.The object to which the specified frameworkTemplate has been applied. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

frameworkTemplate
FrameworkTemplate

애니메이션을 적용할 템플릿입니다.The template to animate.

isControllable
Boolean

스토리보드를 대화형으로 제어할 수 있어야 하는 경우 true이고, 그러지 않으면 false입니다.true if the storyboard should be interactively controllable; otherwise, false.

설명

사용 하 여 대체 됩니다 대상된 속성에 이미 애니메이션이 적용 된 경우는 SnapshotAndReplace 핸드 오프 동작 합니다.If the targeted properties are already animated, they are replaced using the SnapshotAndReplace handoff behavior.

이 스토리 보드를 대화형으로 제어 하려면 지정 해야 동일한 containingObject 시작 스토리 보드를 사용 하는 대화형 메서드를 호출 하는 경우To interactively control this storyboard, you must specify the same containingObject when calling the interactive methods that you used to begin the storyboard

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

Begin(FrameworkContentElement, HandoffBehavior, Boolean)

지정된 Storyboard를 통해 이 HandoffBehavior와 연결된 애니메이션을 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them, using the specified HandoffBehavior.

public:
 void Begin(System::Windows::FrameworkContentElement ^ containingObject, System::Windows::Media::Animation::HandoffBehavior handoffBehavior, bool isControllable);
public void Begin (System.Windows.FrameworkContentElement containingObject, System.Windows.Media.Animation.HandoffBehavior handoffBehavior, bool isControllable);
member this.Begin : System.Windows.FrameworkContentElement * System.Windows.Media.Animation.HandoffBehavior * bool -> unit

매개 변수

containingObject
FrameworkContentElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. 지정된 TargetName이 없는 애니메이션은 containingObject에 적용됩니다.Animations without a specified TargetName are applied to containingObject.

handoffBehavior
HandoffBehavior

새 애니메이션이 현재 애니메이션과 상호 작용하기 위해 사용할 동작입니다.The behavior the new animation should use to interact with any current animations.

isControllable
Boolean

애니메이션을 시작한 후 제어(일시 중지)할 수 있는지 여부를 선언합니다.Declares whether the animation is controllable (can be paused) once started.

예제

다음 예제에서는 제어 가능한 storyboard를 사용 하 여 애니메이션 효과 TextEffect입니다.The following example uses a controllable storyboard to animate a TextEffect. 합니다 TextEffect 내에 포함 된를 FrameworkContentElement의 범위 이름을 지정 합니다.The TextEffect is contained within a FrameworkContentElement's name scope.

/*
    This example shows how to control
    a storyboard after it has started.

*/

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Documents;


namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
{
    public class FrameworkContentElementControlStoryboardExample : FlowDocument
    {
    
        private Storyboard myStoryboard;
        
        public FrameworkContentElementControlStoryboardExample()
        {
        
            // Create a name scope for the document.
            NameScope.SetNameScope(this, new NameScope());        
            this.Background = Brushes.White;
            
            // Create a run of text.
            Run theText = new Run( 
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." + 
                "Ut non lacus. Nullam a ligula id leo adipiscing ornare." +
                " Duis mattis. ");   
                
            // Create a TextEffect
            TextEffect animatedSpecialEffect = new TextEffect();
            animatedSpecialEffect.Foreground = Brushes.OrangeRed;
            animatedSpecialEffect.PositionStart = 0;
            animatedSpecialEffect.PositionCount = 0;
            
            // Assign the TextEffect a name by 
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations            
            this.RegisterName("animatedSpecialEffect", animatedSpecialEffect);  
            
            // Apply the text effect to the run.
            theText.TextEffects = new TextEffectCollection();
            theText.TextEffects.Add(animatedSpecialEffect);
            
            // Create a paragraph to contain the run.
            Paragraph animatedParagraph = new Paragraph(theText);
            animatedParagraph.Background = Brushes.LightGray;
            animatedParagraph.Padding = new Thickness(20);
   
            this.Blocks.Add(animatedParagraph);            
            BlockUIContainer controlsContainer = new BlockUIContainer();                
            
            //
            // Create an animation and a storyboard to animate the
            // text effect.
            //
            Int32Animation countAnimation = 
                new Int32Animation(0, 127, TimeSpan.FromSeconds(10)); 
            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect");
            Storyboard.SetTargetProperty(countAnimation, 
                new PropertyPath(TextEffect.PositionCountProperty));
            myStoryboard = new Storyboard();
            myStoryboard.Children.Add(countAnimation);
            
            //
            // Create some buttons to control the storyboard
            // and a panel to contain them.
            //
            StackPanel buttonPanel = new StackPanel();
            buttonPanel.Orientation = Orientation.Vertical;
            Button beginButton = new Button();
            beginButton.Content = "Begin";
            beginButton.Click += new RoutedEventHandler(beginButton_Clicked);            
            buttonPanel.Children.Add(beginButton);
            Button pauseButton = new Button();
            pauseButton.Content = "Pause";
            pauseButton.Click +=new RoutedEventHandler(pauseButton_Clicked);
            buttonPanel.Children.Add(pauseButton);
            Button resumeButton = new Button();
            resumeButton.Content = "Resume";
            resumeButton.Click +=new RoutedEventHandler(resumeButton_Clicked);
            buttonPanel.Children.Add(resumeButton);
            Button skipToFillButton = new Button();
            skipToFillButton.Content = "Skip to Fill";
            skipToFillButton.Click +=new RoutedEventHandler(skipToFillButton_Clicked);
            buttonPanel.Children.Add(skipToFillButton);
            Button setSpeedRatioButton = new Button();
            setSpeedRatioButton.Content = "Triple Speed";
            setSpeedRatioButton.Click +=new RoutedEventHandler(setSpeedRatioButton_Clicked);
            buttonPanel.Children.Add(setSpeedRatioButton);
            Button stopButton = new Button();
            stopButton.Content = "Stop";
            stopButton.Click +=new RoutedEventHandler(stopButton_Clicked);
            buttonPanel.Children.Add(stopButton);
            Button removeButton = new Button();
            removeButton.Content = "Remove";
            removeButton.Click +=new RoutedEventHandler(removeButton_Clicked);
            buttonPanel.Children.Add(removeButton); 
   
            controlsContainer.Child = buttonPanel; 
            this.Blocks.Add(controlsContainer);
            
        }
        
        // Begins the storyboard.
        private void beginButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Specifying "true" as the second Begin parameter
            // makes this storyboard controllable.
            myStoryboard.Begin(this, true);          
        
        }
        
        // Pauses the storyboard.
        private void pauseButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Pause(this);          
        
        }
        
        // Resumes the storyboard.
        private void resumeButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Resume(this);          
        
        }     
        
        // Advances the storyboard to its fill period.
        private void skipToFillButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.SkipToFill(this);          
        
        } 
        
        // Updates the storyboard's speed.
        private void setSpeedRatioButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Makes the storyboard progress three times as fast as normal.
            myStoryboard.SetSpeedRatio(this, 3);          
        
        }           
        
        // Stops the storyboard.
        private void stopButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Stop(this);          
        
        }     
        
        // Removes the storyboard.
        private void removeButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Remove(this);          
        
        }           

    }
}
'
'    This example shows how to control
'    a storyboard after it has started.
'
'


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


Namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
    Public Class FrameworkContentElementControlStoryboardExample
        Inherits FlowDocument

        Private myStoryboard As Storyboard

        Public Sub New()

            ' Create a name scope for the document.
            NameScope.SetNameScope(Me, New NameScope())
            Me.Background = Brushes.White

            ' Create a run of text.
            Dim theText As New Run("Lorem ipsum dolor sit amet, consectetuer adipiscing elit." & "Ut non lacus. Nullam a ligula id leo adipiscing ornare." & " Duis mattis. ")

            ' Create a TextEffect
            Dim animatedSpecialEffect As New TextEffect()
            animatedSpecialEffect.Foreground = Brushes.OrangeRed
            animatedSpecialEffect.PositionStart = 0
            animatedSpecialEffect.PositionCount = 0

            ' Assign the TextEffect a name by 
            ' registering it with the page, so that
            ' it can be targeted by storyboard
            ' animations            
            Me.RegisterName("animatedSpecialEffect", animatedSpecialEffect)

            ' Apply the text effect to the run.
            theText.TextEffects = New TextEffectCollection()
            theText.TextEffects.Add(animatedSpecialEffect)

            ' Create a paragraph to contain the run.
            Dim animatedParagraph As New Paragraph(theText)
            animatedParagraph.Background = Brushes.LightGray
            animatedParagraph.Padding = New Thickness(20)

            Me.Blocks.Add(animatedParagraph)
            Dim controlsContainer As New BlockUIContainer()

            '
            ' Create an animation and a storyboard to animate the
            ' text effect.
            '
            Dim countAnimation As New Int32Animation(0, 127, TimeSpan.FromSeconds(10))
            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect")
            Storyboard.SetTargetProperty(countAnimation, New PropertyPath(TextEffect.PositionCountProperty))
            myStoryboard = New Storyboard()
            myStoryboard.Children.Add(countAnimation)

            '
            ' Create some buttons to control the storyboard
            ' and a panel to contain them.
            '
            Dim buttonPanel As New StackPanel()
            buttonPanel.Orientation = Orientation.Vertical
            Dim beginButton As New Button()
            beginButton.Content = "Begin"
            AddHandler beginButton.Click, AddressOf beginButton_Clicked
            buttonPanel.Children.Add(beginButton)
            Dim pauseButton As New Button()
            pauseButton.Content = "Pause"
            AddHandler pauseButton.Click, AddressOf pauseButton_Clicked
            buttonPanel.Children.Add(pauseButton)
            Dim resumeButton As New Button()
            resumeButton.Content = "Resume"
            AddHandler resumeButton.Click, AddressOf resumeButton_Clicked
            buttonPanel.Children.Add(resumeButton)
            Dim skipToFillButton As New Button()
            skipToFillButton.Content = "Skip to Fill"
            AddHandler skipToFillButton.Click, AddressOf skipToFillButton_Clicked
            buttonPanel.Children.Add(skipToFillButton)
            Dim setSpeedRatioButton As New Button()
            setSpeedRatioButton.Content = "Triple Speed"
            AddHandler setSpeedRatioButton.Click, AddressOf setSpeedRatioButton_Clicked
            buttonPanel.Children.Add(setSpeedRatioButton)
            Dim stopButton As New Button()
            stopButton.Content = "Stop"
            AddHandler stopButton.Click, AddressOf stopButton_Clicked
            buttonPanel.Children.Add(stopButton)
            Dim removeButton As New Button()
            removeButton.Content = "Remove"
            AddHandler removeButton.Click, AddressOf removeButton_Clicked
            buttonPanel.Children.Add(removeButton)

            controlsContainer.Child = buttonPanel
            Me.Blocks.Add(controlsContainer)

        End Sub

        ' Begins the storyboard.
        Private Sub beginButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            ' Specifying "true" as the second Begin parameter
            ' makes this storyboard controllable.
            myStoryboard.Begin(Me, True)

        End Sub

        ' Pauses the storyboard.
        Private Sub pauseButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Pause(Me)

        End Sub

        ' Resumes the storyboard.
        Private Sub resumeButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Resume(Me)

        End Sub

        ' Advances the storyboard to its fill period.
        Private Sub skipToFillButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.SkipToFill(Me)

        End Sub

        ' Updates the storyboard's speed.
        Private Sub setSpeedRatioButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            ' Makes the storyboard progress three times as fast as normal.
            myStoryboard.SetSpeedRatio(Me, 3)

        End Sub

        ' Stops the storyboard.
        Private Sub stopButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Stop(Me)

        End Sub

        ' Removes the storyboard.
        Private Sub removeButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Remove(Me)

        End Sub

    End Class
End Namespace

다음 예제에서는 합니다 SnapshotAndReplace HandoffBehavior 사용자가, 및 Compose HandoffBehavior 클릭할 때입니다.The next example uses the SnapshotAndReplace HandoffBehavior to animate when the user left-clicks, and the Compose HandoffBehavior when the user right-clicks.

/*
    This example shows how to animate
    a FrameworkContentElement with a storyboard.

*/

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Documents;
using System.Windows.Input;


namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
{
    public class FrameworkContentElementStoryboardWithHandoffBehaviorExample : 
        FlowDocument
    {
    
        private Storyboard myStoryboard;
        DoubleAnimation xAnimation;
        DoubleAnimation yAnimation;
        
        public FrameworkContentElementStoryboardWithHandoffBehaviorExample()
        {
        
            // Create a name scope for the document.
            NameScope.SetNameScope(this, new NameScope());        
            this.Background = Brushes.Orange;
            
            // Create a run of text.
            Run theText = new Run( 
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.");   
                
            // Create a TextEffect
            TextEffect animatedSpecialEffect = new TextEffect();
            animatedSpecialEffect.Foreground = Brushes.OrangeRed;
            animatedSpecialEffect.PositionStart = 0;
            animatedSpecialEffect.PositionCount = 20;
            
            TranslateTransform animatedTransform = 
                new TranslateTransform();
                
            // Assign the transform a name by 
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations.      
            this.RegisterName("animatedTransform", animatedTransform);             
            animatedSpecialEffect.Transform = animatedTransform;
            
            
            // Apply the text effect to the run.
            theText.TextEffects = new TextEffectCollection();
            theText.TextEffects.Add(animatedSpecialEffect);
            
            
            // Create a paragraph to contain the run.
            Paragraph animatedParagraph = new Paragraph(theText);
            animatedParagraph.Background = Brushes.LightGray;           
   
            this.Blocks.Add(animatedParagraph);                           
            
            //
            // Create a storyboard to animate the
            // text effect's transform.
            //
            myStoryboard = new Storyboard();
            
            xAnimation = new DoubleAnimation();  
            xAnimation.Duration = TimeSpan.FromSeconds(5);                        
            Storyboard.SetTargetName(xAnimation, "animatedTransform");
            Storyboard.SetTargetProperty(xAnimation, 
                new PropertyPath(TranslateTransform.XProperty));      
            myStoryboard.Children.Add(xAnimation);
            
            yAnimation = new DoubleAnimation();
            yAnimation.Duration = TimeSpan.FromSeconds(5);           
            Storyboard.SetTargetName(yAnimation, "animatedTransform");
            Storyboard.SetTargetProperty(yAnimation, 
                new PropertyPath(TranslateTransform.YProperty));      
            myStoryboard.Children.Add(yAnimation);            
            
            this.MouseLeftButtonDown += 
                new MouseButtonEventHandler(document_mouseLeftButtonDown);
            this.MouseRightButtonDown += 
                new MouseButtonEventHandler(document_mouseRightButtonDown);
            
        }
              
        

        // When the user left-clicks, use the 
        // SnapshotAndReplace HandoffBehavior when applying the animation.        
        private void document_mouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
        
            Point clickPoint = Mouse.GetPosition(this);
            
      
            // Animate to the target point.
            xAnimation.To = clickPoint.X; 
            yAnimation.To = clickPoint.Y;

            try
            {
                myStoryboard.Begin(this, HandoffBehavior.SnapshotAndReplace);  
            
            }catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        
        // When the user right-clicks, use the 
        // Compose HandoffBehavior when applying the animation.
        private void document_mouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
        

            Point clickPoint = Mouse.GetPosition(this);

            // Animate to the target point.
            xAnimation.To = clickPoint.X;
            yAnimation.To = clickPoint.Y;
            myStoryboard.Begin(this, HandoffBehavior.Compose);  
            
                    
        }        
        
   

 

    }
}
'
'    This example shows how to animate
'    a FrameworkContentElement with a storyboard.
'
'


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


Namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
    Public Class FrameworkContentElementStoryboardWithHandoffBehaviorExample
        Inherits FlowDocument

        Private myStoryboard As Storyboard
        Private xAnimation As DoubleAnimation
        Private yAnimation As DoubleAnimation

        Public Sub New()

            ' Create a name scope for the document.
            NameScope.SetNameScope(Me, New NameScope())
            Me.Background = Brushes.Orange

            ' Create a run of text.
            Dim theText As New Run("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.")

            ' Create a TextEffect
            Dim animatedSpecialEffect As New TextEffect()
            animatedSpecialEffect.Foreground = Brushes.OrangeRed
            animatedSpecialEffect.PositionStart = 0
            animatedSpecialEffect.PositionCount = 20

            Dim animatedTransform As New TranslateTransform()

            ' Assign the transform a name by 
            ' registering it with the page, so that
            ' it can be targeted by storyboard
            ' animations.      
            Me.RegisterName("animatedTransform", animatedTransform)
            animatedSpecialEffect.Transform = animatedTransform


            ' Apply the text effect to the run.
            theText.TextEffects = New TextEffectCollection()
            theText.TextEffects.Add(animatedSpecialEffect)


            ' Create a paragraph to contain the run.
            Dim animatedParagraph As New Paragraph(theText)
            animatedParagraph.Background = Brushes.LightGray

            Me.Blocks.Add(animatedParagraph)

            '
            ' Create a storyboard to animate the
            ' text effect's transform.
            '
            myStoryboard = New Storyboard()

            xAnimation = New DoubleAnimation()
            xAnimation.Duration = TimeSpan.FromSeconds(5)
            Storyboard.SetTargetName(xAnimation, "animatedTransform")
            Storyboard.SetTargetProperty(xAnimation, New PropertyPath(TranslateTransform.XProperty))
            myStoryboard.Children.Add(xAnimation)

            yAnimation = New DoubleAnimation()
            yAnimation.Duration = TimeSpan.FromSeconds(5)
            Storyboard.SetTargetName(yAnimation, "animatedTransform")
            Storyboard.SetTargetProperty(yAnimation, New PropertyPath(TranslateTransform.YProperty))
            myStoryboard.Children.Add(yAnimation)

            AddHandler MouseLeftButtonDown, AddressOf document_mouseLeftButtonDown
            AddHandler MouseRightButtonDown, AddressOf document_mouseRightButtonDown

        End Sub



        ' When the user left-clicks, use the 
        ' SnapshotAndReplace HandoffBehavior when applying the animation.        
        Private Sub document_mouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

            Dim clickPoint As Point = Mouse.GetPosition(Me)


            ' Animate to the target point.
            xAnimation.To = clickPoint.X
            yAnimation.To = clickPoint.Y

            Try
                myStoryboard.Begin(Me, HandoffBehavior.SnapshotAndReplace)

            Catch ex As Exception
                MessageBox.Show(ex.ToString())
            End Try
        End Sub

        ' When the user right-clicks, use the 
        ' Compose HandoffBehavior when applying the animation.
        Private Sub document_mouseRightButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)


            Dim clickPoint As Point = Mouse.GetPosition(Me)

            ' Animate to the target point.
            xAnimation.To = clickPoint.X
            yAnimation.To = clickPoint.Y
            myStoryboard.Begin(Me, HandoffBehavior.Compose)


        End Sub





    End Class
End Namespace

설명

대상된 속성에 이미 애니메이션이 적용 된 경우 지정 된 핸드 오프 동작을 사용 하 여 대체 됩니다.If the targeted properties are already animated, they are replaced using the specified handoff behavior.

이 스토리 보드를 대화형으로 제어 하려면 지정 해야 동일한 containingObject 시작 스토리 보드를 사용 하는 대화형 메서드를 호출 하는 경우To interactively control this storyboard, you must specify the same containingObject when calling the interactive methods that you used to begin the storyboard

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

사용 하 여 Compose HandoffBehaviorUsing the Compose HandoffBehavior

적용 하는 경우는 Storyboard, AnimationTimeline, 또는 AnimationClock 사용 하 여 속성을 Compose HandoffBehavior모든 Clock 개체 속성과 연관 된 이전에 시스템 리소스를 소비 계속; 타이밍 시스템 하지 않습니다 자동으로 이러한 클록을 제거 합니다.When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove these clocks automatically.

많은 수의 시계를 사용 하 여 적용 하는 경우 성능 문제를 방지 하려면 Compose를 완성 한 후 애니메이션된 속성에서 구성 중인 클록을 제거 해야 합니다.To avoid performance issues when you apply a large number of clocks using Compose, you should remove composing clocks from the animated property after they complete. 여러 가지 방법으로 클록을 제거할 수 있습니다.There are several ways to remove a clock.

이것은 주로 수명이 긴 개체에 대한 애니메이션에서 문제가 됩니다.This is primarily an issue for animations on objects that have a long lifetime. 개체는 가비지 수집 되 면 해당 클록도 연결이 끊어집니다 및 가비지 수집 합니다.When an object is garbage collected, its clocks are also disconnected and garbage collected.

클록 개체에 대 한 자세한 내용은 참조 하세요. 애니메이션 및 타이밍 시스템 개요합니다.For more information about clock objects, see Animation and Timing System Overview.

Begin(FrameworkElement, FrameworkTemplate)

Storyboard와 연결된 애니메이션을 지정된 템플릿 내의 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets within the specified template and initiates them.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject, System::Windows::FrameworkTemplate ^ frameworkTemplate);
public void Begin (System.Windows.FrameworkElement containingObject, System.Windows.FrameworkTemplate frameworkTemplate);
member this.Begin : System.Windows.FrameworkElement * System.Windows.FrameworkTemplate -> unit

매개 변수

containingObject
FrameworkElement

지정된 frameworkTemplate을 적용한 개체입니다.The object to which the specified frameworkTemplate has been applied. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

frameworkTemplate
FrameworkTemplate

애니메이션을 적용할 템플릿입니다.The template to animate.

설명

사용 하 여 대체 됩니다 대상된 속성에 이미 애니메이션이 적용 된 경우는 SnapshotAndReplace 핸드 오프 동작 합니다.If the targeted properties are already animated, they are replaced using the SnapshotAndReplace handoff behavior.

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

Begin(FrameworkElement, HandoffBehavior)

지정된 Storyboard를 통해 이 HandoffBehavior와 연결된 애니메이션을 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them, using the specified HandoffBehavior.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void Begin (System.Windows.FrameworkElement containingObject, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
member this.Begin : System.Windows.FrameworkElement * System.Windows.Media.Animation.HandoffBehavior -> unit

매개 변수

containingObject
FrameworkElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. 지정된 TargetName이 없는 애니메이션은 containingObject에 적용됩니다.Animations without a specified TargetName are applied to containingObject.

handoffBehavior
HandoffBehavior

새 애니메이션이 현재 애니메이션과 상호 작용하기 위해 사용할 동작입니다.The behavior the new animation should use to interact with any current animations.

예제

다음 예제에서는 합니다 SnapshotAndReplace HandoffBehavior 사용자가, 및 Compose HandoffBehavior 클릭할 때입니다.The following example uses the SnapshotAndReplace HandoffBehavior to animate when the user left-clicks, and the Compose HandoffBehavior when the user right-clicks.

/*

   This sample animates the position of an ellipse when 
   the user clicks within the main border. If the user
   left-clicks, the SnapshotAndReplace HandoffBehavior
   is used when applying the animations. If the user
   right-clicks, the Compose HandoffBehavior is used
   instead.

*/

using System;
using System.Windows;
using System.Windows.Navigation;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Input;

namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
{

    // Create the demonstration.
    public class FrameworkElementStoryboardHandoffBehaviorExample : Page {
        
        
        private Border containerBorder;
        private Ellipse interactiveEllipse;
        private Storyboard theStoryboard;
        private DoubleAnimation xAnimation;
        private DoubleAnimation yAnimation;
        
        public FrameworkElementStoryboardHandoffBehaviorExample()
        {
        
            WindowTitle = "Interactive Animation Example";
            
            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());  
            
            DockPanel myPanel = new DockPanel();
            myPanel.Margin = new Thickness(20.0);            
    
            containerBorder = new Border();
            containerBorder.Background = Brushes.White;
            containerBorder.BorderBrush = Brushes.Black;
            containerBorder.BorderThickness = new Thickness(2.0); 
            containerBorder.VerticalAlignment = VerticalAlignment.Stretch;
            
            interactiveEllipse = new Ellipse();
            interactiveEllipse.Fill = Brushes.Lime;
            interactiveEllipse.Stroke = Brushes.Black;
            interactiveEllipse.StrokeThickness = 2.0;
            interactiveEllipse.Width = 25;
            interactiveEllipse.Height = 25;
            interactiveEllipse.HorizontalAlignment = HorizontalAlignment.Left;
            interactiveEllipse.VerticalAlignment = VerticalAlignment.Top;
            

            TranslateTransform interactiveTranslateTransform = new TranslateTransform();       
            this.RegisterName("InteractiveTranslateTransform", interactiveTranslateTransform);
            
            interactiveEllipse.RenderTransform = 
                interactiveTranslateTransform;
                
            xAnimation = new DoubleAnimation();
            xAnimation.Duration = TimeSpan.FromSeconds(4);
            yAnimation = xAnimation.Clone();
            Storyboard.SetTargetName(xAnimation, "InteractiveTranslateTransform");
            Storyboard.SetTargetProperty(xAnimation, new PropertyPath(TranslateTransform.XProperty));
            Storyboard.SetTargetName(yAnimation, "InteractiveTranslateTransform");
            Storyboard.SetTargetProperty(yAnimation, new PropertyPath(TranslateTransform.YProperty));            
            
            theStoryboard = new Storyboard();
            theStoryboard.Children.Add(xAnimation);
            theStoryboard.Children.Add(yAnimation);
                
                
            containerBorder.MouseLeftButtonDown += 
                new MouseButtonEventHandler(border_mouseLeftButtonDown);
            containerBorder.MouseRightButtonDown += 
                new MouseButtonEventHandler(border_mouseRightButtonDown);                
            
            containerBorder.Child = interactiveEllipse;
            myPanel.Children.Add(containerBorder);
            this.Content = myPanel;
        }
        

        // When the user left-clicks, use the 
        // SnapshotAndReplace HandoffBehavior when applying the animation.        
        private void border_mouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
        
            Point clickPoint = Mouse.GetPosition(containerBorder);
            
            // Set the target point so the center of the ellipse
            // ends up at the clicked point.
            Point targetPoint = new Point();
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2;
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2;  
            
            // Animate to the target point.
            xAnimation.To = targetPoint.X;
            yAnimation.To = targetPoint.Y;
            theStoryboard.Begin(this, HandoffBehavior.SnapshotAndReplace);
            

            // Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Lime;
                    
        }
        
        // When the user right-clicks, use the 
        // Compose HandoffBehavior when applying the animation.
        private void border_mouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
        
            // Find the point where the use clicked.
            Point clickPoint = Mouse.GetPosition(containerBorder);
            
            // Set the target point so the center of the ellipse
            // ends up at the clicked point.
            Point targetPoint = new Point();
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2;
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2;
 
            // Animate to the target point.
            xAnimation.To = targetPoint.X;
            yAnimation.To = targetPoint.Y;
            theStoryboard.Begin(this, HandoffBehavior.Compose);
                
            // Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Orange;
            
                    
        }
        
    }
 
}
'
'
'   This sample animates the position of an ellipse when 
'   the user clicks within the main border. If the user
'   left-clicks, the SnapshotAndReplace HandoffBehavior
'   is used when applying the animations. If the user
'   right-clicks, the Compose HandoffBehavior is used
'   instead.
'
'


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

Namespace Microsoft.Samples.Animation.AnimatingWithStoryboards

    ' Create the demonstration.
    Public Class FrameworkElementStoryboardHandoffBehaviorExample
        Inherits Page


        Private containerBorder As Border
        Private interactiveEllipse As Ellipse
        Private theStoryboard As Storyboard
        Private xAnimation As DoubleAnimation
        Private yAnimation As DoubleAnimation

        Public Sub New()

            WindowTitle = "Interactive Animation Example"

            ' Create a name scope for the page.
            NameScope.SetNameScope(Me, New NameScope())

            Dim myPanel As New DockPanel()
            myPanel.Margin = New Thickness(20.0)

            containerBorder = New Border()
            containerBorder.Background = Brushes.White
            containerBorder.BorderBrush = Brushes.Black
            containerBorder.BorderThickness = New Thickness(2.0)
            containerBorder.VerticalAlignment = VerticalAlignment.Stretch

            interactiveEllipse = New Ellipse()
            With interactiveEllipse
                .Fill = Brushes.Lime
                .Stroke = Brushes.Black
                .StrokeThickness = 2.0
                .Width = 25
                .Height = 25
                .HorizontalAlignment = HorizontalAlignment.Left
                .VerticalAlignment = VerticalAlignment.Top
            End With

            Dim interactiveTranslateTransform As New TranslateTransform()
            Me.RegisterName("InteractiveTranslateTransform", interactiveTranslateTransform)

            interactiveEllipse.RenderTransform = interactiveTranslateTransform

            xAnimation = New DoubleAnimation()
            xAnimation.Duration = TimeSpan.FromSeconds(4)
            yAnimation = xAnimation.Clone()
            Storyboard.SetTargetName(xAnimation, "InteractiveTranslateTransform")
            Storyboard.SetTargetProperty(xAnimation, New PropertyPath(TranslateTransform.XProperty))
            Storyboard.SetTargetName(yAnimation, "InteractiveTranslateTransform")
            Storyboard.SetTargetProperty(yAnimation, New PropertyPath(TranslateTransform.YProperty))

            theStoryboard = New Storyboard()
            theStoryboard.Children.Add(xAnimation)
            theStoryboard.Children.Add(yAnimation)


            AddHandler containerBorder.MouseLeftButtonDown, AddressOf border_mouseLeftButtonDown
            AddHandler containerBorder.MouseRightButtonDown, AddressOf border_mouseRightButtonDown

            containerBorder.Child = interactiveEllipse
            myPanel.Children.Add(containerBorder)
            Me.Content = myPanel
        End Sub


        ' When the user left-clicks, use the 
        ' SnapshotAndReplace HandoffBehavior when applying the animation.        
        Private Sub border_mouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

            Dim clickPoint As Point = Mouse.GetPosition(containerBorder)

            ' Set the target point so the center of the ellipse
            ' ends up at the clicked point.
            Dim targetPoint As New Point()
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2

            ' Animate to the target point.
            xAnimation.To = targetPoint.X
            yAnimation.To = targetPoint.Y
            theStoryboard.Begin(Me, HandoffBehavior.SnapshotAndReplace)


            ' Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Lime

        End Sub

        ' When the user right-clicks, use the 
        ' Compose HandoffBehavior when applying the animation.
        Private Sub border_mouseRightButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

            ' Find the point where the use clicked.
            Dim clickPoint As Point = Mouse.GetPosition(containerBorder)

            ' Set the target point so the center of the ellipse
            ' ends up at the clicked point.
            Dim targetPoint As New Point()
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2

            ' Animate to the target point.
            xAnimation.To = targetPoint.X
            yAnimation.To = targetPoint.Y
            theStoryboard.Begin(Me, HandoffBehavior.Compose)

            ' Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Orange


        End Sub

    End Class

End Namespace

Begin(FrameworkContentElement, HandoffBehavior)

지정된 Storyboard를 통해 이 HandoffBehavior와 연결된 애니메이션을 해당 대상에 적용하여 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them, using the specified HandoffBehavior.

public:
 void Begin(System::Windows::FrameworkContentElement ^ containingObject, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void Begin (System.Windows.FrameworkContentElement containingObject, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
member this.Begin : System.Windows.FrameworkContentElement * System.Windows.Media.Animation.HandoffBehavior -> unit

매개 변수

containingObject
FrameworkContentElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

handoffBehavior
HandoffBehavior

새 애니메이션이 현재 애니메이션과 상호 작용하기 위해 사용할 동작입니다.The behavior the new animation should use to interact with any current animations.

예제

다음 예제에서는 합니다 SnapshotAndReplace HandoffBehavior 사용자가, 및 Compose HandoffBehavior 클릭할 때입니다.The following example uses the SnapshotAndReplace HandoffBehavior to animate when the user left-clicks, and the Compose HandoffBehavior when the user right-clicks.

/*
    This example shows how to animate
    a FrameworkContentElement with a storyboard.

*/

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Documents;
using System.Windows.Input;


namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
{
    public class FrameworkContentElementStoryboardWithHandoffBehaviorExample : 
        FlowDocument
    {
    
        private Storyboard myStoryboard;
        DoubleAnimation xAnimation;
        DoubleAnimation yAnimation;
        
        public FrameworkContentElementStoryboardWithHandoffBehaviorExample()
        {
        
            // Create a name scope for the document.
            NameScope.SetNameScope(this, new NameScope());        
            this.Background = Brushes.Orange;
            
            // Create a run of text.
            Run theText = new Run( 
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.");   
                
            // Create a TextEffect
            TextEffect animatedSpecialEffect = new TextEffect();
            animatedSpecialEffect.Foreground = Brushes.OrangeRed;
            animatedSpecialEffect.PositionStart = 0;
            animatedSpecialEffect.PositionCount = 20;
            
            TranslateTransform animatedTransform = 
                new TranslateTransform();
                
            // Assign the transform a name by 
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations.      
            this.RegisterName("animatedTransform", animatedTransform);             
            animatedSpecialEffect.Transform = animatedTransform;
            
            
            // Apply the text effect to the run.
            theText.TextEffects = new TextEffectCollection();
            theText.TextEffects.Add(animatedSpecialEffect);
            
            
            // Create a paragraph to contain the run.
            Paragraph animatedParagraph = new Paragraph(theText);
            animatedParagraph.Background = Brushes.LightGray;           
   
            this.Blocks.Add(animatedParagraph);                           
            
            //
            // Create a storyboard to animate the
            // text effect's transform.
            //
            myStoryboard = new Storyboard();
            
            xAnimation = new DoubleAnimation();  
            xAnimation.Duration = TimeSpan.FromSeconds(5);                        
            Storyboard.SetTargetName(xAnimation, "animatedTransform");
            Storyboard.SetTargetProperty(xAnimation, 
                new PropertyPath(TranslateTransform.XProperty));      
            myStoryboard.Children.Add(xAnimation);
            
            yAnimation = new DoubleAnimation();
            yAnimation.Duration = TimeSpan.FromSeconds(5);           
            Storyboard.SetTargetName(yAnimation, "animatedTransform");
            Storyboard.SetTargetProperty(yAnimation, 
                new PropertyPath(TranslateTransform.YProperty));      
            myStoryboard.Children.Add(yAnimation);            
            
            this.MouseLeftButtonDown += 
                new MouseButtonEventHandler(document_mouseLeftButtonDown);
            this.MouseRightButtonDown += 
                new MouseButtonEventHandler(document_mouseRightButtonDown);
            
        }
              
        

        // When the user left-clicks, use the 
        // SnapshotAndReplace HandoffBehavior when applying the animation.        
        private void document_mouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
        
            Point clickPoint = Mouse.GetPosition(this);
            
      
            // Animate to the target point.
            xAnimation.To = clickPoint.X; 
            yAnimation.To = clickPoint.Y;

            try
            {
                myStoryboard.Begin(this, HandoffBehavior.SnapshotAndReplace);  
            
            }catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        
        // When the user right-clicks, use the 
        // Compose HandoffBehavior when applying the animation.
        private void document_mouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
        

            Point clickPoint = Mouse.GetPosition(this);

            // Animate to the target point.
            xAnimation.To = clickPoint.X;
            yAnimation.To = clickPoint.Y;
            myStoryboard.Begin(this, HandoffBehavior.Compose);  
            
                    
        }        
        
   

 

    }
}
'
'    This example shows how to animate
'    a FrameworkContentElement with a storyboard.
'
'


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


Namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
    Public Class FrameworkContentElementStoryboardWithHandoffBehaviorExample
        Inherits FlowDocument

        Private myStoryboard As Storyboard
        Private xAnimation As DoubleAnimation
        Private yAnimation As DoubleAnimation

        Public Sub New()

            ' Create a name scope for the document.
            NameScope.SetNameScope(Me, New NameScope())
            Me.Background = Brushes.Orange

            ' Create a run of text.
            Dim theText As New Run("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.")

            ' Create a TextEffect
            Dim animatedSpecialEffect As New TextEffect()
            animatedSpecialEffect.Foreground = Brushes.OrangeRed
            animatedSpecialEffect.PositionStart = 0
            animatedSpecialEffect.PositionCount = 20

            Dim animatedTransform As New TranslateTransform()

            ' Assign the transform a name by 
            ' registering it with the page, so that
            ' it can be targeted by storyboard
            ' animations.      
            Me.RegisterName("animatedTransform", animatedTransform)
            animatedSpecialEffect.Transform = animatedTransform


            ' Apply the text effect to the run.
            theText.TextEffects = New TextEffectCollection()
            theText.TextEffects.Add(animatedSpecialEffect)


            ' Create a paragraph to contain the run.
            Dim animatedParagraph As New Paragraph(theText)
            animatedParagraph.Background = Brushes.LightGray

            Me.Blocks.Add(animatedParagraph)

            '
            ' Create a storyboard to animate the
            ' text effect's transform.
            '
            myStoryboard = New Storyboard()

            xAnimation = New DoubleAnimation()
            xAnimation.Duration = TimeSpan.FromSeconds(5)
            Storyboard.SetTargetName(xAnimation, "animatedTransform")
            Storyboard.SetTargetProperty(xAnimation, New PropertyPath(TranslateTransform.XProperty))
            myStoryboard.Children.Add(xAnimation)

            yAnimation = New DoubleAnimation()
            yAnimation.Duration = TimeSpan.FromSeconds(5)
            Storyboard.SetTargetName(yAnimation, "animatedTransform")
            Storyboard.SetTargetProperty(yAnimation, New PropertyPath(TranslateTransform.YProperty))
            myStoryboard.Children.Add(yAnimation)

            AddHandler MouseLeftButtonDown, AddressOf document_mouseLeftButtonDown
            AddHandler MouseRightButtonDown, AddressOf document_mouseRightButtonDown

        End Sub



        ' When the user left-clicks, use the 
        ' SnapshotAndReplace HandoffBehavior when applying the animation.        
        Private Sub document_mouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

            Dim clickPoint As Point = Mouse.GetPosition(Me)


            ' Animate to the target point.
            xAnimation.To = clickPoint.X
            yAnimation.To = clickPoint.Y

            Try
                myStoryboard.Begin(Me, HandoffBehavior.SnapshotAndReplace)

            Catch ex As Exception
                MessageBox.Show(ex.ToString())
            End Try
        End Sub

        ' When the user right-clicks, use the 
        ' Compose HandoffBehavior when applying the animation.
        Private Sub document_mouseRightButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)


            Dim clickPoint As Point = Mouse.GetPosition(Me)

            ' Animate to the target point.
            xAnimation.To = clickPoint.X
            yAnimation.To = clickPoint.Y
            myStoryboard.Begin(Me, HandoffBehavior.Compose)


        End Sub





    End Class
End Namespace

설명

적용 하는 경우는 Storyboard, AnimationTimeline, 또는 AnimationClock 사용 하 여 속성을 Compose HandoffBehavior모든 Clock 개체 속성과 연관 된 이전에 시스템 리소스를 소비 계속; 타이밍 시스템 하지 않습니다 자동으로 이러한 클록을 제거 합니다.When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove these clocks automatically.

많은 수의 시계를 사용 하 여 적용 하는 경우 성능 문제를 방지 하려면 Compose를 완성 한 후 애니메이션된 속성에서 구성 중인 클록을 제거 해야 합니다.To avoid performance issues when you apply a large number of clocks using Compose, you should remove composing clocks from the animated property after they complete. 여러 가지 방법으로 클록을 제거할 수 있습니다.There are several ways to remove a clock.

이것은 주로 수명이 긴 개체에 대한 애니메이션에서 문제가 됩니다.This is primarily an issue for animations on objects that have a long lifetime. 개체는 가비지 수집 되 면 해당 클록도 연결이 끊어집니다 및 가비지 수집 합니다.When an object is garbage collected, its clocks are also disconnected and garbage collected.

클록 개체에 대 한 자세한 내용은 참조 하세요. 애니메이션 및 타이밍 시스템 개요합니다.For more information about clock objects, see Animation and Timing System Overview.

Begin(FrameworkContentElement, Boolean)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

public:
 void Begin(System::Windows::FrameworkContentElement ^ containingObject, bool isControllable);
public void Begin (System.Windows.FrameworkContentElement containingObject, bool isControllable);
member this.Begin : System.Windows.FrameworkContentElement * bool -> unit
Public Sub Begin (containingObject As FrameworkContentElement, isControllable As Boolean)

매개 변수

containingObject
FrameworkContentElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

isControllable
Boolean

스토리보드를 대화형으로 제어할 수 있어야 하는 경우 true이고, 그러지 않으면 false입니다.true if the storyboard should be interactively controllable; otherwise, false.

예제

다음 예제에서는 제어 가능한 storyboard를 사용 하 여 애니메이션 효과 TextEffect입니다.The following example uses a controllable storyboard to animate a TextEffect. 합니다 TextEffect 내에 포함 된를 FrameworkContentElement의 범위 이름을 지정 합니다.The TextEffect is contained within a FrameworkContentElement's name scope.

/*
    This example shows how to control
    a storyboard after it has started.

*/

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Documents;


namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
{
    public class FrameworkContentElementControlStoryboardExample : FlowDocument
    {
    
        private Storyboard myStoryboard;
        
        public FrameworkContentElementControlStoryboardExample()
        {
        
            // Create a name scope for the document.
            NameScope.SetNameScope(this, new NameScope());        
            this.Background = Brushes.White;
            
            // Create a run of text.
            Run theText = new Run( 
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." + 
                "Ut non lacus. Nullam a ligula id leo adipiscing ornare." +
                " Duis mattis. ");   
                
            // Create a TextEffect
            TextEffect animatedSpecialEffect = new TextEffect();
            animatedSpecialEffect.Foreground = Brushes.OrangeRed;
            animatedSpecialEffect.PositionStart = 0;
            animatedSpecialEffect.PositionCount = 0;
            
            // Assign the TextEffect a name by 
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations            
            this.RegisterName("animatedSpecialEffect", animatedSpecialEffect);  
            
            // Apply the text effect to the run.
            theText.TextEffects = new TextEffectCollection();
            theText.TextEffects.Add(animatedSpecialEffect);
            
            // Create a paragraph to contain the run.
            Paragraph animatedParagraph = new Paragraph(theText);
            animatedParagraph.Background = Brushes.LightGray;
            animatedParagraph.Padding = new Thickness(20);
   
            this.Blocks.Add(animatedParagraph);            
            BlockUIContainer controlsContainer = new BlockUIContainer();                
            
            //
            // Create an animation and a storyboard to animate the
            // text effect.
            //
            Int32Animation countAnimation = 
                new Int32Animation(0, 127, TimeSpan.FromSeconds(10)); 
            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect");
            Storyboard.SetTargetProperty(countAnimation, 
                new PropertyPath(TextEffect.PositionCountProperty));
            myStoryboard = new Storyboard();
            myStoryboard.Children.Add(countAnimation);
            
            //
            // Create some buttons to control the storyboard
            // and a panel to contain them.
            //
            StackPanel buttonPanel = new StackPanel();
            buttonPanel.Orientation = Orientation.Vertical;
            Button beginButton = new Button();
            beginButton.Content = "Begin";
            beginButton.Click += new RoutedEventHandler(beginButton_Clicked);            
            buttonPanel.Children.Add(beginButton);
            Button pauseButton = new Button();
            pauseButton.Content = "Pause";
            pauseButton.Click +=new RoutedEventHandler(pauseButton_Clicked);
            buttonPanel.Children.Add(pauseButton);
            Button resumeButton = new Button();
            resumeButton.Content = "Resume";
            resumeButton.Click +=new RoutedEventHandler(resumeButton_Clicked);
            buttonPanel.Children.Add(resumeButton);
            Button skipToFillButton = new Button();
            skipToFillButton.Content = "Skip to Fill";
            skipToFillButton.Click +=new RoutedEventHandler(skipToFillButton_Clicked);
            buttonPanel.Children.Add(skipToFillButton);
            Button setSpeedRatioButton = new Button();
            setSpeedRatioButton.Content = "Triple Speed";
            setSpeedRatioButton.Click +=new RoutedEventHandler(setSpeedRatioButton_Clicked);
            buttonPanel.Children.Add(setSpeedRatioButton);
            Button stopButton = new Button();
            stopButton.Content = "Stop";
            stopButton.Click +=new RoutedEventHandler(stopButton_Clicked);
            buttonPanel.Children.Add(stopButton);
            Button removeButton = new Button();
            removeButton.Content = "Remove";
            removeButton.Click +=new RoutedEventHandler(removeButton_Clicked);
            buttonPanel.Children.Add(removeButton); 
   
            controlsContainer.Child = buttonPanel; 
            this.Blocks.Add(controlsContainer);
            
        }
        
        // Begins the storyboard.
        private void beginButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Specifying "true" as the second Begin parameter
            // makes this storyboard controllable.
            myStoryboard.Begin(this, true);          
        
        }
        
        // Pauses the storyboard.
        private void pauseButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Pause(this);          
        
        }
        
        // Resumes the storyboard.
        private void resumeButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Resume(this);          
        
        }     
        
        // Advances the storyboard to its fill period.
        private void skipToFillButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.SkipToFill(this);          
        
        } 
        
        // Updates the storyboard's speed.
        private void setSpeedRatioButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Makes the storyboard progress three times as fast as normal.
            myStoryboard.SetSpeedRatio(this, 3);          
        
        }           
        
        // Stops the storyboard.
        private void stopButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Stop(this);          
        
        }     
        
        // Removes the storyboard.
        private void removeButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Remove(this);          
        
        }           

    }
}
'
'    This example shows how to control
'    a storyboard after it has started.
'
'


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


Namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
    Public Class FrameworkContentElementControlStoryboardExample
        Inherits FlowDocument

        Private myStoryboard As Storyboard

        Public Sub New()

            ' Create a name scope for the document.
            NameScope.SetNameScope(Me, New NameScope())
            Me.Background = Brushes.White

            ' Create a run of text.
            Dim theText As New Run("Lorem ipsum dolor sit amet, consectetuer adipiscing elit." & "Ut non lacus. Nullam a ligula id leo adipiscing ornare." & " Duis mattis. ")

            ' Create a TextEffect
            Dim animatedSpecialEffect As New TextEffect()
            animatedSpecialEffect.Foreground = Brushes.OrangeRed
            animatedSpecialEffect.PositionStart = 0
            animatedSpecialEffect.PositionCount = 0

            ' Assign the TextEffect a name by 
            ' registering it with the page, so that
            ' it can be targeted by storyboard
            ' animations            
            Me.RegisterName("animatedSpecialEffect", animatedSpecialEffect)

            ' Apply the text effect to the run.
            theText.TextEffects = New TextEffectCollection()
            theText.TextEffects.Add(animatedSpecialEffect)

            ' Create a paragraph to contain the run.
            Dim animatedParagraph As New Paragraph(theText)
            animatedParagraph.Background = Brushes.LightGray
            animatedParagraph.Padding = New Thickness(20)

            Me.Blocks.Add(animatedParagraph)
            Dim controlsContainer As New BlockUIContainer()

            '
            ' Create an animation and a storyboard to animate the
            ' text effect.
            '
            Dim countAnimation As New Int32Animation(0, 127, TimeSpan.FromSeconds(10))
            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect")
            Storyboard.SetTargetProperty(countAnimation, New PropertyPath(TextEffect.PositionCountProperty))
            myStoryboard = New Storyboard()
            myStoryboard.Children.Add(countAnimation)

            '
            ' Create some buttons to control the storyboard
            ' and a panel to contain them.
            '
            Dim buttonPanel As New StackPanel()
            buttonPanel.Orientation = Orientation.Vertical
            Dim beginButton As New Button()
            beginButton.Content = "Begin"
            AddHandler beginButton.Click, AddressOf beginButton_Clicked
            buttonPanel.Children.Add(beginButton)
            Dim pauseButton As New Button()
            pauseButton.Content = "Pause"
            AddHandler pauseButton.Click, AddressOf pauseButton_Clicked
            buttonPanel.Children.Add(pauseButton)
            Dim resumeButton As New Button()
            resumeButton.Content = "Resume"
            AddHandler resumeButton.Click, AddressOf resumeButton_Clicked
            buttonPanel.Children.Add(resumeButton)
            Dim skipToFillButton As New Button()
            skipToFillButton.Content = "Skip to Fill"
            AddHandler skipToFillButton.Click, AddressOf skipToFillButton_Clicked
            buttonPanel.Children.Add(skipToFillButton)
            Dim setSpeedRatioButton As New Button()
            setSpeedRatioButton.Content = "Triple Speed"
            AddHandler setSpeedRatioButton.Click, AddressOf setSpeedRatioButton_Clicked
            buttonPanel.Children.Add(setSpeedRatioButton)
            Dim stopButton As New Button()
            stopButton.Content = "Stop"
            AddHandler stopButton.Click, AddressOf stopButton_Clicked
            buttonPanel.Children.Add(stopButton)
            Dim removeButton As New Button()
            removeButton.Content = "Remove"
            AddHandler removeButton.Click, AddressOf removeButton_Clicked
            buttonPanel.Children.Add(removeButton)

            controlsContainer.Child = buttonPanel
            Me.Blocks.Add(controlsContainer)

        End Sub

        ' Begins the storyboard.
        Private Sub beginButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            ' Specifying "true" as the second Begin parameter
            ' makes this storyboard controllable.
            myStoryboard.Begin(Me, True)

        End Sub

        ' Pauses the storyboard.
        Private Sub pauseButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Pause(Me)

        End Sub

        ' Resumes the storyboard.
        Private Sub resumeButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Resume(Me)

        End Sub

        ' Advances the storyboard to its fill period.
        Private Sub skipToFillButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.SkipToFill(Me)

        End Sub

        ' Updates the storyboard's speed.
        Private Sub setSpeedRatioButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
            ' Makes the storyboard progress three times as fast as normal.
            myStoryboard.SetSpeedRatio(Me, 3)

        End Sub

        ' Stops the storyboard.
        Private Sub stopButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Stop(Me)

        End Sub

        ' Removes the storyboard.
        Private Sub removeButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)
             myStoryboard.Remove(Me)

        End Sub

    End Class
End Namespace

설명

사용 하 여 대체 됩니다 대상된 속성에 이미 애니메이션이 적용 된 경우는 SnapshotAndReplace 핸드 오프 동작 합니다.If the targeted properties are already animated, they are replaced using the SnapshotAndReplace handoff behavior.

이 스토리 보드를 대화형으로 제어 하려면 지정 해야 동일한 containingObject 시작 스토리 보드를 사용 하는 대화형 메서드를 호출 하는 경우To interactively control this storyboard, you must specify the same containingObject when calling the interactive methods that you used to begin the storyboard

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

Begin(FrameworkElement)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject);
public void Begin (System.Windows.FrameworkElement containingObject);
member this.Begin : System.Windows.FrameworkElement -> unit
Public Sub Begin (containingObject As FrameworkElement)

매개 변수

containingObject
FrameworkElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

설명

사용 하 여 대체 됩니다 대상된 속성에 이미 애니메이션이 적용 된 경우는 SnapshotAndReplace 핸드 오프 동작 합니다.If the targeted properties are already animated, they are replaced using the SnapshotAndReplace handoff behavior.

이 메서드를 사용 하 여 시작 하는 스토리 보드는 일시 중지, 다시 시작 하거나 그렇지 않으면 시작한 후 대화형으로 제어할 수 수 없습니다.Storyboards started with this method cannot be paused, resumed, or otherwise interactively controlled after they are started. Storyboard를 제어할 수 있도록 하려면 사용 합니다 Begin(FrameworkElement, Boolean) 또는 Begin(FrameworkElement, HandoffBehavior, Boolean) 메서드.To make a storyboard controllable, use the Begin(FrameworkElement, Boolean) or Begin(FrameworkElement, HandoffBehavior, Boolean) method.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

Begin(FrameworkContentElement)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

public:
 void Begin(System::Windows::FrameworkContentElement ^ containingObject);
public void Begin (System.Windows.FrameworkContentElement containingObject);
member this.Begin : System.Windows.FrameworkContentElement -> unit
Public Sub Begin (containingObject As FrameworkContentElement)

매개 변수

containingObject
FrameworkContentElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

예제

다음 예제에서는 storyboard를 사용 하 여 애니메이션 효과 TextEffect입니다.The following example uses a storyboard to animate a TextEffect. 합니다 TextEffect 내에 포함 된를 FrameworkContentElement의 범위 이름을 지정 합니다.The TextEffect is contained within a FrameworkContentElement's name scope.

/*
    This example shows how to animate
    a FrameworkContentElement with a storyboard.

*/

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Documents;


namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
{
    public class FrameworkContentElementStoryboardExample : FlowDocument
    {
    
        private Storyboard myStoryboard;
        
        public FrameworkContentElementStoryboardExample()
        {
        
            // Create a name scope for the document.
            NameScope.SetNameScope(this, new NameScope());        
            this.Background = Brushes.White;
            
            // Create a run of text.
            Run theText = new Run( 
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." + 
                "Ut non lacus. Nullam a ligula id leo adipiscing ornare." +
                " Duis mattis. ");   
                
            // Create a TextEffect
            TextEffect animatedSpecialEffect = new TextEffect();
            animatedSpecialEffect.Foreground = Brushes.OrangeRed;
            animatedSpecialEffect.PositionStart = 0;
            animatedSpecialEffect.PositionCount = 0;
            
            // Assign the TextEffect a name by 
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations            
            this.RegisterName("animatedSpecialEffect", animatedSpecialEffect);  
            
            // Apply the text effect to the run.
            theText.TextEffects = new TextEffectCollection();
            theText.TextEffects.Add(animatedSpecialEffect);
            
            // Create a paragraph to contain the run.
            Paragraph animatedParagraph = new Paragraph(theText);
            animatedParagraph.Background = Brushes.LightGray;
            animatedParagraph.Padding = new Thickness(20);
   
            this.Blocks.Add(animatedParagraph);            
            BlockUIContainer controlsContainer = new BlockUIContainer();                
            
            //
            // Create an animation and a storyboard to animate the
            // text effect.
            //
            Int32Animation countAnimation = 
                new Int32Animation(0, 127, TimeSpan.FromSeconds(10));            
            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect");
            Storyboard.SetTargetProperty(countAnimation, 
                new PropertyPath(TextEffect.PositionCountProperty));
            myStoryboard = new Storyboard();
            myStoryboard.Children.Add(countAnimation);
            
            //
            // Create a button to start the storyboard.
            //
            Button beginButton = new Button();
            beginButton.Content = "Begin";
            beginButton.Click += new RoutedEventHandler(beginButton_Clicked);            
 
            controlsContainer.Child = beginButton; 
            this.Blocks.Add(controlsContainer);
            
        }
        
        // Begins the storyboard.
        private void beginButton_Clicked(object sender, RoutedEventArgs args)
        {
        
            myStoryboard.Begin(this);                  
        }
        
 

    }
}
'
'    This example shows how to animate
'    a FrameworkContentElement with a storyboard.
'
'


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


Namespace Microsoft.Samples.Animation.AnimatingWithStoryboards
    Public Class FrameworkContentElementStoryboardExample
        Inherits FlowDocument

        Private myStoryboard As Storyboard

        Public Sub New()

            ' Create a name scope for the document.
            NameScope.SetNameScope(Me, New NameScope())
            Me.Background = Brushes.White

            ' Create a run of text.
            Dim theText As New Run("Lorem ipsum dolor sit amet, consectetuer adipiscing elit." & "Ut non lacus. Nullam a ligula id leo adipiscing ornare." & " Duis mattis. ")

            ' Create a TextEffect
            Dim animatedSpecialEffect As New TextEffect()
            animatedSpecialEffect.Foreground = Brushes.OrangeRed
            animatedSpecialEffect.PositionStart = 0
            animatedSpecialEffect.PositionCount = 0

            ' Assign the TextEffect a name by 
            ' registering it with the page, so that
            ' it can be targeted by storyboard
            ' animations            
            Me.RegisterName("animatedSpecialEffect", animatedSpecialEffect)

            ' Apply the text effect to the run.
            theText.TextEffects = New TextEffectCollection()
            theText.TextEffects.Add(animatedSpecialEffect)

            ' Create a paragraph to contain the run.
            Dim animatedParagraph As New Paragraph(theText)
            animatedParagraph.Background = Brushes.LightGray
            animatedParagraph.Padding = New Thickness(20)

            Me.Blocks.Add(animatedParagraph)
            Dim controlsContainer As New BlockUIContainer()

            '
            ' Create an animation and a storyboard to animate the
            ' text effect.
            '
            Dim countAnimation As New Int32Animation(0, 127, TimeSpan.FromSeconds(10))
            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect")
            Storyboard.SetTargetProperty(countAnimation, New PropertyPath(TextEffect.PositionCountProperty))
            myStoryboard = New Storyboard()
            myStoryboard.Children.Add(countAnimation)

            '
            ' Create a button to start the storyboard.
            '
            Dim beginButton As New Button()
            beginButton.Content = "Begin"
            AddHandler beginButton.Click, AddressOf beginButton_Clicked

            controlsContainer.Child = beginButton
            Me.Blocks.Add(controlsContainer)

        End Sub

        ' Begins the storyboard.
        Private Sub beginButton_Clicked(ByVal sender As Object, ByVal args As RoutedEventArgs)

            myStoryboard.Begin(Me)
        End Sub



    End Class
End Namespace

설명

사용 하 여 대체 됩니다 대상된 속성에 이미 애니메이션이 적용 된 경우는 SnapshotAndReplace 핸드 오프 동작 합니다.If the targeted properties are already animated, they are replaced using the SnapshotAndReplace handoff behavior.

이 메서드를 사용 하 여 시작 하는 스토리 보드는 일시 중지, 다시 시작 하거나 그렇지 않으면 시작한 후 대화형으로 제어할 수 수 없습니다.Storyboards started with this method cannot be paused, resumed, or otherwise interactively controlled after they are started. Storyboard를 제어할 수 있도록 하려면 사용 합니다 Begin 또는 Begin 메서드.To make a storyboard controllable, use the Begin or Begin method.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

Begin()

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

public:
 void Begin();
public void Begin ();
member this.Begin : unit -> unit
Public Sub Begin ()

Begin(FrameworkElement, Boolean)

Storyboard와 연결된 애니메이션을 해당 대상에 적용하고 시작합니다.Applies the animations associated with this Storyboard to their targets and initiates them.

public:
 void Begin(System::Windows::FrameworkElement ^ containingObject, bool isControllable);
public void Begin (System.Windows.FrameworkElement containingObject, bool isControllable);
member this.Begin : System.Windows.FrameworkElement * bool -> unit
Public Sub Begin (containingObject As FrameworkElement, isControllable As Boolean)

매개 변수

containingObject
FrameworkElement

이 스토리보드의 애니메이션 대상과 동일한 이름 범위 내에 포함된 개체입니다.An object contained within the same name scope as the targets of this storyboard's animations. TargetName이 없는 애니메이션이 containingObject에 적용됩니다.Animations without a TargetName are applied to containingObject.

isControllable
Boolean

스토리보드를 대화형으로 제어할 수 있어야 하는 경우 true이고, 그러지 않으면 false입니다.true if the storyboard should be interactively controllable; otherwise, false.

설명

사용 하 여 대체 됩니다 대상된 속성에 이미 애니메이션이 적용 된 경우는 SnapshotAndReplace 핸드 오프 동작 합니다.If the targeted properties are already animated, they are replaced using the SnapshotAndReplace handoff behavior.

이 스토리 보드를 대화형으로 제어 하려면 사용 해야 동일한 containingObject 스토리 보드를 시작 하는 데는 대화형 메서드를 호출할 때 매개 변수To interactively control this storyboard, you must use the same containingObject parameter when calling the interactive methods that you used to begin the storyboard

이 메서드를 호출 하는 경우 Clock 스토리 보드 및 포함 된 모든 타임 라인에 대해 개체가 만들어집니다.When this method is called, Clock objects are created for the storyboard and any timelines it contains. 이러한 클록와 함께 저장 됩니다 containingObject합니다.These clocks are stored with containingObject.

스토리 보드 트리거를 시작 합니다 CurrentStateInvalidatedCurrentGlobalSpeedInvalidated 이벤트입니다.Beginning a storyboard triggers the CurrentStateInvalidated and CurrentGlobalSpeedInvalidated events.

적용 대상