The property triggers described in the previous chapter let you detect specific property values and change some property's value in response. For example, a
Button might detect when
True and change its scale to make the
Button grow when the mouse is over it.
Event triggers and animation add a new dimension to this type of responsiveness. An event trigger lets you detect when an event occurs. Animation lets you change property values in a series of smoothly varying steps. Together, for example, you can make a
Button detect the
MouseOver event and use animation to enlarge the
Button, providing graphical feedback similar to the experience provided by the previous property event.
So, what's the difference? First, WPF controls provide many events that are not provided by watching property values. For example, while a
Button has an
IsMouseOver property to tell you when the mouse is over it, there are no properties that directly correspond to the events
MouseEnter, MouseLeave, MouseDown, MouseUp, MouseMove, and
Second, a setter used by property triggers immediately changes a property's value. In contrast, an animation makes a property value gradually change over time. The end result is similar, but the user can see the change in the value as it happens. For example, instead of making a button suddenly pop to a new size, an animation makes it gradually grow. Often the difference isn't critical — the button ends up with the same ...