MCTS Self-Paced Training: Styles and Animation in Windows Presentation Foundation
- 7/9/2008
Chapter Summary
Styles allow you to define consistent visual styles for your application by using a collection of Setters. They usually are defined as a Resource and referenced in XAML, though they can be set inline or dynamically. Styles can be inherited from other styles and applied to all instances of a particular type.
Triggers respond to changes in the application environment. Property triggers and multi-triggers listen for changes in property values, and data triggers and multi-data-triggers listen for changes in bound values. When one of these triggers is activated, its Setters collection is applied. EventTriggers listen for a routed event and execute Actions in response to that event.
Property values follow a strict order of precedence depending on how they are set.
Animation objects drive automated property changes over time. There are three different types of Animation objects—linear animations, key frame–based animations, and path-based animations. Every animatable type has one or more Animation classes that can be used with it. Animations are organized by Storyboard objects, which are themselves controlled by Action objects that are activated in the Action collections of Trigger objects.
Animations that use key frames provide waypoints that the Animation visits as it progresses. Key frames can be linear, spline-based, or discrete.
You can create and apply Animation objects in code. When doing this, you do not need to define a Storyboard object, but rather you call the BeginAnimation method on the element with which you want to associate the Animation.