"should i use wpf converter or trigger?" Code Answer

3

i agree with you, i also try to use declarative code in xaml and prefer triggers instead of converters.

in most of the scenarios triggers can perform the same work as any converter but converters can have custom/business logic as pchajer mentioned.

one limitation of triggers is that setters in your datatriggers can only change properties of your ui elements; so, you can't update your viewmodels property with triggers, thats where converters win, remember the convertback method.

so, you can bind your vm property with a controls visibility using booleantovisibilityconverter and even if your controls visibility is changed by some other means your vm property will get updated; generally it's not required that's why booleantovisibilityconverter gets replaced by triggers.

so in short -

triggers can only perform oneway operations whereas converters can perform twoway operations

By chinsoon12 on July 20 2022

Answers related to “should i use wpf converter or trigger?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.