Animatable.BeginAnimation Animatable.BeginAnimation Animatable.BeginAnimation Animatable.BeginAnimation Method

정의

지정된 DependencyProperty에 애니메이션을 적용합니다.Applies an animation to the specified DependencyProperty.

오버로드

BeginAnimation(DependencyProperty, AnimationTimeline) BeginAnimation(DependencyProperty, AnimationTimeline) BeginAnimation(DependencyProperty, AnimationTimeline) BeginAnimation(DependencyProperty, AnimationTimeline)

지정된 DependencyProperty에 애니메이션을 적용합니다.Applies an animation to the specified DependencyProperty. 애니메이션은 다음 프레임을 렌더링할 때 시작됩니다.The animation is started when the next frame is rendered. 지정된 속성에 이미 애니메이션 효과가 적용되어 있으면 SnapshotAndReplace 전달 동작이 사용됩니다.If the specified property is already animated, the SnapshotAndReplace handoff behavior is used.

BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior) BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior) BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

지정된 DependencyProperty에 애니메이션을 적용합니다.Applies an animation to the specified DependencyProperty. 애니메이션은 다음 프레임을 렌더링할 때 시작됩니다.The animation is started when the next frame is rendered. 지정된 속성에 이미 애니메이션이 적용되어 있으면 지정된 HandoffBehavior가 사용됩니다.If the specified property is already animated, the specified HandoffBehavior is used.

BeginAnimation(DependencyProperty, AnimationTimeline) BeginAnimation(DependencyProperty, AnimationTimeline) BeginAnimation(DependencyProperty, AnimationTimeline) BeginAnimation(DependencyProperty, AnimationTimeline)

지정된 DependencyProperty에 애니메이션을 적용합니다.Applies an animation to the specified DependencyProperty. 애니메이션은 다음 프레임을 렌더링할 때 시작됩니다.The animation is started when the next frame is rendered. 지정된 속성에 이미 애니메이션 효과가 적용되어 있으면 SnapshotAndReplace 전달 동작이 사용됩니다.If the specified property is already animated, the SnapshotAndReplace handoff behavior is used.

public:
 virtual void BeginAnimation(System::Windows::DependencyProperty ^ dp, System::Windows::Media::Animation::AnimationTimeline ^ animation);
public void BeginAnimation (System.Windows.DependencyProperty dp, System.Windows.Media.Animation.AnimationTimeline animation);
abstract member BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline -> unit
override this.BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline -> unit
Public Sub BeginAnimation (dp As DependencyProperty, animation As AnimationTimeline)

매개 변수

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

애니메이션 효과를 주는 속성입니다.The property to animate.

animation
AnimationTimeline AnimationTimeline AnimationTimeline AnimationTimeline

지정된 속성에 애니메이션 효과를 주는 데 사용할 애니메이션입니다.The animation used to animate the specified property.

애니메이션의 BeginTimenull이면 현재 애니메이션이 모두 제거되고 속성의 현재 값이 유지됩니다.If the animation's BeginTime is null, any current animations will be removed and the current value of the property will be held.

animationnull이면 모든 애니메이션이 속성에서 제거되고 속성 값이 기준 값으로 돌아갑니다.If animation is null, all animations will be removed from the property and the property value will revert back to its base value.

구현

설명

애니메이션에는 BeginTime 0 보다 큰, 다음 프레임이 렌더링 되는 시간에서 시간 경과 후 애니메이션을 시작 합니다.If the animation has a BeginTime that is greater than zero, the animation begins after that amount of time has elapsed from the time the next frame is rendered.

BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior) BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior) BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

지정된 DependencyProperty에 애니메이션을 적용합니다.Applies an animation to the specified DependencyProperty. 애니메이션은 다음 프레임을 렌더링할 때 시작됩니다.The animation is started when the next frame is rendered. 지정된 속성에 이미 애니메이션이 적용되어 있으면 지정된 HandoffBehavior가 사용됩니다.If the specified property is already animated, the specified HandoffBehavior is used.

public:
 virtual void BeginAnimation(System::Windows::DependencyProperty ^ dp, System::Windows::Media::Animation::AnimationTimeline ^ animation, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void BeginAnimation (System.Windows.DependencyProperty dp, System.Windows.Media.Animation.AnimationTimeline animation, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
abstract member BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline * System.Windows.Media.Animation.HandoffBehavior -> unit
override this.BeginAnimation : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationTimeline * System.Windows.Media.Animation.HandoffBehavior -> unit

매개 변수

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

애니메이션 효과를 주는 속성입니다.The property to animate.

animation
AnimationTimeline AnimationTimeline AnimationTimeline AnimationTimeline

지정된 속성에 애니메이션 효과를 주는 데 사용할 애니메이션입니다.The animation used to animate the specified property.

handoffBehaviorSnapshotAndReplace이고 애니메이션의 BeginTimenull이면 현재 애니메이션은 제거되며 속성의 현재 값이 유지됩니다.If handoffBehavior is SnapshotAndReplace and the animation's BeginTime is null, any current animations will be removed and the current value of the property will be held.

handoffBehaviorSnapshotAndReplace이고 animationnull 참조이면 모든 애니메이션이 속성에서 제거되며 속성 값이 기준 값으로 되돌아갑니다.If handoffBehavior is SnapshotAndReplace and animation is a null reference, all animations will be removed from the property and the property value will revert back to its base value.

handoffBehaviorCompose인 경우 애니메이션 또는 해당 BeginTimenull이면 이 메서드를 사용해도 아무런 영향이 없습니다.If handoffBehavior is Compose, this method will have no effect if the animation or its BeginTime is null.

handoffBehavior
HandoffBehavior HandoffBehavior HandoffBehavior HandoffBehavior

새 애니메이션이 이미 속성 값에 영향을 주고 있는 현재 애니메이션과 상호 작용하는 방법을 지정하는 값입니다.A value that specifies how the new animation should interact with any current animations already affecting the property value.

구현

예제

다음 예제에서는 다른을 사용 하 여 애니메이션을 적용 하는 방법을 보여 줍니다 HandoffBehavior 설정 합니다.The following example shows how to apply animations using different HandoffBehavior settings.

/*

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 namespace System;
using namespace System::Windows;
using namespace System::Windows::Navigation;
using namespace System::Windows::Media;
using namespace System::Windows::Media::Animation;
using namespace System::Windows::Shapes;
using namespace System::Windows::Controls;
using namespace System::Windows::Input;

namespace Microsoft {
   namespace Samples {
      namespace Animation {
         namespace LocalAnimations {
            public ref class InteractiveAnimationExample : Page {
            private: 
               TranslateTransform^ interactiveTranslateTransform;
               Border^ containerBorder;
               Ellipse^ interactiveEllipse;

            public: 
               InteractiveAnimationExample () 
               {
                  WindowTitle = "Interactive Animation Example";
                  DockPanel^ myPanel = gcnew DockPanel();
                  myPanel->Margin = Thickness(20.0);

                  containerBorder = gcnew Border();
                  containerBorder->Background = Brushes::White;
                  containerBorder->BorderBrush = Brushes::Black;
                  containerBorder->BorderThickness = Thickness(2.0);
                  containerBorder->VerticalAlignment = System::Windows::VerticalAlignment::Stretch;

                  interactiveEllipse = gcnew Ellipse();
                  interactiveEllipse->Fill = Brushes::Lime;
                  interactiveEllipse->Stroke = Brushes::Black;
                  interactiveEllipse->StrokeThickness = 2.0;
                  interactiveEllipse->Width = 25;
                  interactiveEllipse->Height = 25;
                  interactiveEllipse->HorizontalAlignment = System::Windows::HorizontalAlignment::Left;
                  interactiveEllipse->VerticalAlignment = System::Windows::VerticalAlignment::Top;

                  interactiveTranslateTransform = gcnew TranslateTransform();
                  interactiveEllipse->RenderTransform = interactiveTranslateTransform;

                  containerBorder->MouseLeftButtonDown += 
                     gcnew MouseButtonEventHandler(this, &Microsoft::Samples::Animation::LocalAnimations::InteractiveAnimationExample::border_mouseLeftButtonDown);
                  containerBorder->MouseRightButtonDown += 
                     gcnew MouseButtonEventHandler(this, &Microsoft::Samples::Animation::LocalAnimations::InteractiveAnimationExample::border_mouseRightButtonDown);
                  containerBorder->Child = interactiveEllipse;

                  myPanel->Children->Add(containerBorder);
                  this->Content = myPanel;
               };

            private: 
               // When the user left-clicks, use the 
               // SnapshotAndReplace HandoffBehavior when applying the animation.        
               void border_mouseLeftButtonDown (System::Object^ sender, System::Windows::Input::MouseButtonEventArgs^ e)
               {
                  System::Windows::Point clickPoint = Mouse::GetPosition(containerBorder);

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

                  // Animate to the target point.
                  DoubleAnimation^ xAnimation = gcnew DoubleAnimation(targetPoint.X,
                     Duration(TimeSpan::FromSeconds(4)));
                  interactiveTranslateTransform->BeginAnimation(TranslateTransform::XProperty, xAnimation, HandoffBehavior::SnapshotAndReplace);

                  DoubleAnimation^ yAnimation = gcnew DoubleAnimation(targetPoint.Y,
                     Duration(TimeSpan::FromSeconds(4)));
                  interactiveTranslateTransform->BeginAnimation(TranslateTransform::YProperty, yAnimation, HandoffBehavior::SnapshotAndReplace);

                  // Chage the color of the ellipse.
                  interactiveEllipse->Fill = Brushes::Lime;
               }

            private:
               // When the user right-clicks, use the 
               // Compose HandoffBehavior when applying the animation.
               void border_mouseRightButtonDown (System::Object^ sender, System::Windows::Input::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 = System::Windows::Point();
                  targetPoint.X = clickPoint.X - interactiveEllipse->Width / 2;
                  targetPoint.Y = clickPoint.Y - interactiveEllipse->Height / 2;

                  // Animate to the target point.
                  DoubleAnimation^ xAnimation = gcnew DoubleAnimation(targetPoint.X,
                     Duration(TimeSpan::FromSeconds(4)));
                  interactiveTranslateTransform->BeginAnimation(TranslateTransform::XProperty, xAnimation, HandoffBehavior::Compose);

                  DoubleAnimation^ yAnimation = gcnew DoubleAnimation(targetPoint.Y,
                     Duration(TimeSpan::FromSeconds(4)));

                  // Change the color of the ellipse.
                  interactiveTranslateTransform->BeginAnimation(TranslateTransform::YProperty, yAnimation, HandoffBehavior::Compose);
                  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.

*/

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.LocalAnimations
{

    // Create the demonstration.
    public class InteractiveAnimationExample : Page {
        
        
        private TranslateTransform interactiveTranslateTransform;   
        private Border containerBorder;
        private Ellipse interactiveEllipse;
        
        public InteractiveAnimationExample()
        {
        
            WindowTitle = "Interactive Animation Example";
            DockPanel myPanel = new DockPanel();
            myPanel.Margin = new Thickness(20.0);            
    
            containerBorder = new Border();
            containerBorder.Background = System.Windows.Media.Brushes.White;
            containerBorder.BorderBrush = System.Windows.Media.Brushes.Black;
            containerBorder.BorderThickness = new Thickness(2.0); 
            containerBorder.VerticalAlignment = VerticalAlignment.Stretch;
            
            interactiveEllipse = new Ellipse();
            interactiveEllipse.Fill = System.Windows.Media.Brushes.Lime;
            interactiveEllipse.Stroke = System.Windows.Media.Brushes.Black;
            interactiveEllipse.StrokeThickness = 2.0;
            interactiveEllipse.Width = 25;
            interactiveEllipse.Height = 25;
            interactiveEllipse.HorizontalAlignment = HorizontalAlignment.Left;
            interactiveEllipse.VerticalAlignment = VerticalAlignment.Top;
            
            interactiveTranslateTransform = new TranslateTransform();
            interactiveEllipse.RenderTransform = 
                interactiveTranslateTransform;
                
            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)
        {
        
            System.Windows.Point clickPoint = Mouse.GetPosition(containerBorder);
            
            // Set the target point so the center of the ellipse
            // ends up at the clicked point.
            System.Windows.Point targetPoint = new System.Windows.Point();
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2;
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2;  
            
            // Animate to the target point.
            DoubleAnimation xAnimation = 
                new DoubleAnimation(targetPoint.X, 
                new Duration(TimeSpan.FromSeconds(4)));
            interactiveTranslateTransform.BeginAnimation(
                TranslateTransform.XProperty, xAnimation, HandoffBehavior.SnapshotAndReplace);
                
            DoubleAnimation yAnimation = 
                new DoubleAnimation(targetPoint.Y, 
                new Duration(TimeSpan.FromSeconds(4))); 
            interactiveTranslateTransform.BeginAnimation(
                TranslateTransform.YProperty, yAnimation, HandoffBehavior.SnapshotAndReplace);                

            // Change the color of the ellipse.
            interactiveEllipse.Fill = System.Windows.Media.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.
            System.Windows.Point clickPoint = Mouse.GetPosition(containerBorder);
            
            // Set the target point so the center of the ellipse
            // ends up at the clicked point.
            System.Windows.Point targetPoint = new System.Windows.Point();
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2;
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2;
            
            
            
            // Animate to the target point.
            DoubleAnimation xAnimation = 
                new DoubleAnimation(targetPoint.X, 
                new Duration(TimeSpan.FromSeconds(4)));
            interactiveTranslateTransform.BeginAnimation(
                TranslateTransform.XProperty, xAnimation, HandoffBehavior.Compose);
                
            DoubleAnimation yAnimation = 
                new DoubleAnimation(targetPoint.Y, 
                new Duration(TimeSpan.FromSeconds(4))); 
            interactiveTranslateTransform.BeginAnimation(
                TranslateTransform.YProperty, yAnimation, HandoffBehavior.Compose);   
                
            // Change the color of the ellipse.
            interactiveEllipse.Fill = System.Windows.Media.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
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.LocalAnimations


    ' Create the demonstration.
    Public Class InteractiveAnimationExample
    	Inherits Page
        
        
        Private Dim interactiveTranslateTransform As TranslateTransform  
        Private Dim WithEvents containerBorder As Border 
        Private Dim interactiveEllipse As Ellipse
        
        Public Sub New()
        
            WindowTitle = "Interactive Animation Example"
            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()
            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
            
            interactiveTranslateTransform = new TranslateTransform()
            interactiveEllipse.RenderTransform = _
                interactiveTranslateTransform           
            
            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) _
       		Handles containerBorder.MouseLeftButtonDown
     
        
            Dim clickPoint = Mouse.GetPosition(containerBorder)
            
            ' Set the target point so the center of the ellipse
            ' ends up at the clicked point.
            Dim targetPoint As New System.Windows.Point()
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2  
            
            ' Animate to the target point.
            Dim xAnimation As _ 
                New DoubleAnimation(targetPoint.X,  _
                New Duration(TimeSpan.FromSeconds(4)))
            interactiveTranslateTransform.BeginAnimation( _
                TranslateTransform.XProperty, xAnimation, HandoffBehavior.SnapshotAndReplace)
                
            Dim yAnimation As _ 
                New DoubleAnimation(targetPoint.Y, _
                New Duration(TimeSpan.FromSeconds(4)))
            interactiveTranslateTransform.BeginAnimation( _
                TranslateTransform.YProperty, yAnimation, 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) _
        	Handles containerBorder.MouseRightButtonDown
        
        
            ' Find the point where the use clicked.
            Dim clickPoint = Mouse.GetPosition(containerBorder)
            
            ' Set the target point so the center of the ellipse
            ' ends up at the clicked point.
            Dim targetPoint As New System.Windows.Point()
            targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
            targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2
            
            ' Animate to the target point.
            Dim xAnimation As _
                New DoubleAnimation(targetPoint.X, _
                New Duration(TimeSpan.FromSeconds(4)))
            interactiveTranslateTransform.BeginAnimation( _
                TranslateTransform.XProperty, xAnimation, HandoffBehavior.Compose)
                
            Dim yAnimation As _ 
                New DoubleAnimation(targetPoint.Y, _
                New Duration(TimeSpan.FromSeconds(4))) 
            interactiveTranslateTransform.BeginAnimation( _
                TranslateTransform.YProperty, yAnimation, HandoffBehavior.Compose)   
                
            ' Change the color of the ellipse.
            interactiveEllipse.Fill = Brushes.Orange
            
                    
        End Sub
        
    End Class
 
End Namespace

설명

애니메이션에는 BeginTime 0 보다 큰, 다음 프레임이 렌더링 되는 시간에서 시간 경과 후 애니메이션을 시작 합니다.If the animation has a BeginTime that is greater than zero, the animation begins after that amount of time has elapsed from the time the next frame is rendered.

사용 하 여 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 will 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 will also be disconnected and garbage collected.

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

적용 대상