-
Book Overview & Buying
-
Table Of Contents
Windows Presentation Foundation 4.5 Cookbook
By :
So far we've used styles that have a collection of setters. A Style also has a Triggers collection property that provides a declarative way to make some property changes without a need for actual code. As such triggers are part of a style, they are naturally applied to more than one element. There are three types of triggers supported by WPF, and in this recipe we'll examine the simplest one - the property trigger.
Open the CH08.StyledCalculator project.
We'll add an effect when clicking a button in the calculator project using a property trigger:
We want to add a trigger to one of the styles we created in an earlier recipe. Open MainWindow.xaml and look for the style with the key numericStyle.
Add a Triggers property inside the style:
<Style.Triggers> </Style.Triggers>
Add a property trigger inside the style (after the setters, before the closing style tag). The trigger will be invoked when the IsPressed property is changed to...