--- title: "How to: Animate a Property by Using a Storyboard" description: Enliven your user interface with animations and storyboards for properties in Windows Presentation Foundation (WPF). ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "animation [WPF], Storyboards" - "Storyboards [WPF], animation" ms.assetid: f4a314e9-1da2-4367-85fc-1232487efa7a --- # How to: Animate a Property by Using a Storyboard This example shows how to use a to animate properties. To animate a property by using a , create an animation for each property that you want to animate and also create a to contain the animations. The type of property determines the type of animation to use. For example, to animate a property that takes values, use a . The and attached properties specify the object and property to which the animation is applied. To start a storyboard in [!INCLUDE[TLA#tla_xaml](../../../includes/tlasharptla-xaml-md.md)], use a action and an . The begins the action when the event that is specified by its property occurs. The action starts the . The following example uses objects to animate two controls. To make the first button change in size, its is animated. To make the second button change color, the property of the is used to set the of the button that is animated. ## Example [!code-xaml[AnimatePropertyStoryboards#1](~/samples/snippets/xaml/VS_Snippets_Wpf/AnimatePropertyStoryboards/XAML/StoryboardExample.xaml#1)] > [!NOTE] > Although animations can target both a object, such as a or , and a object, such as a or , only framework elements have a property. To assign a name to a freezable so that it can be targeted by an animation, use the [x:Name Directive](/dotnet/desktop/xaml-services/xname-directive), as the previous example shows. If you use code, you must create a for a and register the names of the objects to animate with that . To start the animations in code, use a action with an . Optionally, you can use an event handler and the method of . The following example shows how to use the method. [!code-csharp[AnimatePropertyStoryboards#11](~/samples/snippets/csharp/VS_Snippets_Wpf/AnimatePropertyStoryboards/CSharp/StoryboardExample.cs#11)] [!code-vb[AnimatePropertyStoryboards#11](~/samples/snippets/visualbasic/VS_Snippets_Wpf/AnimatePropertyStoryboards/VisualBasic/StoryboardExample.vb#11)] For more information about animation and storyboards, see [Animation Overview](animation-overview.md). If you use code, you are not limited to using objects in order to animate properties. For more information and examples, see [Animate a Property Without Using a Storyboard](how-to-animate-a-property-without-using-a-storyboard.md) and [Animate a Property by Using an AnimationClock](how-to-animate-a-property-by-using-an-animationclock.md).