BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
We think - cautiously - that WPF is a better platform for client tool development than Windows Forms. This blog gives 10 reasons why.
- 10 reasons why WPF is better than Windows Forms
- WPF Forms are Quicker to Create
- Flow Layout Trumps Absolute Positioning
- WPF Works for Websites
- Styles are Much Better in WPF
- WPF is (I think) the Way of the Future
- Better Data Binding
- Selecting Controls in the Document Outline Window
- Triggers (this blog)
- StoryBoards and Animations
- Drawing!
Posted by Andy Brown on 25 September 2012
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
8 - Triggers
There are two main types of trigger in WPF: property triggers and event triggers.
Property Triggers
In Windows Forms, if you want a text box to be shaded when you mouse over it, you have to code this.

When you move the mouse over this textbox, it should go pink.
In WPF you can just write a property trigger in XAML:

The trigger which makes this work: when the IsMouseOver property of the textbox becomes true, change the background colour to Pink.
Event Triggers
Event triggers have two main extra features: they allow controls to interact with each other, and they produce animated effects. So you could (for example) get a form to gradually change background from white to grey when you hover over an OK button - but to do that we'll need to have a look at storyboards and animation, the next part of this blog series.
- 10 reasons why WPF is better than Windows Forms
- WPF Forms are Quicker to Create
- Flow Layout Trumps Absolute Positioning
- WPF Works for Websites
- Styles are Much Better in WPF
- WPF is (I think) the Way of the Future
- Better Data Binding
- Selecting Controls in the Document Outline Window
- Triggers (this blog)
- StoryBoards and Animations
- Drawing!