Reputation: 2754
If I wanted to hide(or change visibility, color, etc) of an element in WPF is it better to use DataTrigger or a binding with a converter?
Sounds like two ways to achieve the same goal. When is it better to user one over another?
Upvotes: 3
Views: 771
Reputation: 14037
I can tell you about my experience.
I use databinding with converters for the following cases:
Visibility
property (there is the built-in converter in WPF).Microsoft.Expression.Interactions
library, they are not as convenient as WPF triggers).Datatriggers:
Sometimes I prefer the MVVM approach: I create additional properties of the necessary type in the viewmodel so that they can be bound directly without converting.
Upvotes: 8
Reputation: 38333
The short answer is it depends.
Data Triggers only offer equality operations against a single data source.
If you need to have parameters or multi-value binding you would need to use a converter.
Upvotes: 0