If you use code, you must create a NameScope for a FrameworkElement and register the names of the objects to animate with that FrameworkElement. To assign a name to a freezable so that it can be targeted by an animation, use the x:Name Directive, as the previous example shows. Example Īlthough animations can target both a FrameworkElement object, such as a Control or Panel, and a Freezable object, such as a Brush or Transform, only framework elements have a Name property. To make the second button change color, the Color property of the SolidColorBrush is used to set the Background of the button that is animated. To make the first button change in size, its Width is animated. The following example uses Storyboard objects to animate two Button controls. The BeginStoryboard action starts the Storyboard. The EventTrigger begins the BeginStoryboard action when the event that is specified by its RoutedEvent property occurs. To start a storyboard in Extensible Application Markup Language (XAML), use a BeginStoryboard action and an EventTrigger. The TargetName and TargetProperty attached properties specify the object and property to which the animation is applied. For example, to animate a property that takes Double values, use a DoubleAnimation. The type of property determines the type of animation to use. To animate a property by using a Storyboard, create an animation for each property that you want to animate and also create a Storyboard to contain the animations. This example shows how to use a Storyboard to animate properties.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |