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.
I have 2 view model in main window
In which i have 1 button in one view model, while in my other view model i have a panel and initially tht panel is visible=fALSE
I want tht while i click on tht button the panel from another view model will be visible
Last Visit: 31-Dec-99 18:00 Last Update: 5-Jul-22 2:08