Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between a Trigger and a DataTrigger?

They seem the same. Is there a significant difference? I think I am missing something.

like image 521
Jerry Nixon Avatar asked Jun 27 '11 21:06

Jerry Nixon


People also ask

What is DataTrigger in WPF?

A DataTrigger allows you to set property values when the property value of the data object matches a specified Value. For example, if you are displaying a list of Employee objects, you may want the foreground color to be different based on each Employee's current attendance.

What is trigger in XAML?

Basically, a trigger enables you to change property values or take actions based on the value of a property. So, it basically allows you to dynamically change the appearance and/or behavior of your control without having to create a new one.

Which of the following triggers are available in WPF?

There are five types of triggers supported by WPF; they are: Property Trigger. Data Trigger. MultiTrigger.


1 Answers

A regular Trigger only responds to dependency properties.

A DataTrigger can be triggered by any .NET property (by setting its Binding property). However, its setters can still target only dependency properties.

like image 115
Sean U Avatar answered Sep 23 '22 15:09

Sean U