WPF launches VS converter

Which is better to use performance? Converter limitation compared to a trigger and vice versa. Should I use a converter because it can cause a class explosion?

+7
triggers converter wpf
source share
3 answers

If you are developing TDD, it is better to choose converters.

If there is no complex business logic or user logic that applies, go to triggers. Another thing about converters is that there is a performance hit associated with using converters according to Laurent Bugnion (creator of MVVM Light).

You can see more performance information received in this post. DataTrigger versus data binding with converter efficiency

You can get more detailed information about when to use a trigger and when to use converters from this message. Should I use a WPF converter or trigger?

A decision can be made based on a development approach that you are following or are about to follow. I prefer most often to wrap your view model in the WPF Viewmodel concept.

+5
source share

For a similar type of output, Triggers more efficient than Converter . Although conveters recommended if you want your development to be TDD, since you can write unit tests for your converter code. Converters can be used to write complex transformations that are sometimes impossible to use with triggers. For complex conversions, Converters can reduce code rather than write a series of Triggers .

0
source share

In most scenarios, triggers can do the same job as any converter, but converters can have user / business logic.

One limitation of triggers is that setters in your DataTriggers can change the properties of your user interface elements; therefore, you cannot update the ViewModels property with triggers, that is, where the converters win, remember the ConvertBack method.

In short, triggers can only perform OneWay operations, while inverters can perform TwoWay operations

0
source share

All Articles