If you convert them yourself, you'll need to convert all of them. You really only care about the ones the user is looking at. If you have 100,000 items and the user only looks at 100, there is no need to do the computations to convert the rest. The IValueConverter will accomplish this for you. It'll only call in to do the conversion on whats needed by the UI. Small optimization, but can make a huge difference in performance.
There's a couple of ways you could do this. One way is to hook into the property itself and call the method when you're changing the value. The other way is to use RX to observe the property and call the method whenever the property changes. There's a pretty decent primer here[^] that should give you a heads up.
Well I implemented this and it doesn't work. I registered the property, compiled, and ran it. Nothing happens. The method I registered doesn't get called. The property IS changed, but the callback doesn't get called.
Too bad, it looked promising.
So here's what I just found....
I have a GridView bound to a list of JobAssignmentEntities and who's SelectedItem is bound to a property in my VM called SelectedJobAssignment.
In the CTOR of the VM I did
propertyObserver = new PropertyObserver<JobAssignmentHeaderEntity>(this.SelectedJobAssignment)
.RegisterHandler(n => n.PhaseStart, n => this.phaseStartChanged(n));
In order to register it the property must not be null, because of a null ref check in the register method.
So I moved the block above inside the SelectedJobAssignment's Getter and it works.
sooo, I will need to find a way to register EACH time the SelectedJobAssignment is set.
Yes, this makes sense.
The PropertyObserver constructor attaches to the current value (this.SelectedJobAssignment) of the passed property.
It does not automatically track if that property itself changes. (I.e., it doesn't notice if this.SelectedJobAssignment changes)
The registration tracks if the referenced property of that value changes. (I.e., it only notices if this.SelectedJobAssignment.PhaseStart changes)
You just use a different property observer.
One for "the class" that checks when specific properties are changed.
In the handlers for that observers, you register handlers for the properties on the values of the "properties of the class".
This way the PropertyObserver handles the general case.
Simply you can achieve this by using triggers.
Write an Event Trigger with event name as Click and bind an ICommand property which is in the viewmodel.
So whenever there is a click on the checkbox(either select or deselect this method triggers)
Then you can write the logic according to your functionality.