Question

I am making a WPF Datagrid with lots of related columns. When you change X, Y should be X + Z. Etc. My first idea was to do this in the ViewModel properties with INotifyPropertyChanged. But I see that this also can be done with WPF triggers.

IMHO

If I do it with ViewModel/INotifyPropertyChanged there will be a problem with the first time initializing, where you do not want these rules to execute. I guess I could come around this by setting the private variables in a constructor. The WPF trigger solution seems to be more complex and much more difficult to test.

Question

Are there any advantages letting WPF triggers do the job?

Was it helpful?

Solution

You've asked a bit of a subjective question here without much possibility of a definitive answer. However, I'm going to give it a try.

In my opinion, I would always manipulate data in the view model, for two main reasons:

  1. Data manipulation = business rules and that belongs in the view model and not the view
  2. You have access to every property of the data item(s) and every method in .NET in the view model, but access to very little in a Trigger.

I hope that helps in some small way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top