views:

20

answers:

1

Like the title says I am trying to architecture into my application a way to distinguish the source of a variable change, either from UI or code-behind.

My problem is that I need to trigger some action after a property changed its value, but I only need to do this when the change comes from the UI because otherwise I don-t want to perform that action. I am having some trouble because, for example when a checkbox(two way binding), changes state, my binded property gets updated and then I use the checked and uncheked events to trigger that action.The problem is that when I change the property in codebehind it also triggers those events and I do not want that. Right now, i am using a flag that enables, or not, the actions at the event handlers but I do not feel that this is a good idea.

Any sugestions or ideas? I am considering using only one-way binding and control everything my self, using commands.

A: 

It looks like you have some confusion between your model and your controller. There shouldn't be any cases where it matters if the a change to the model comes from the user or not. If you want to have something like a confirm message it the user makes the change, then don't bind the view control directly to the model, but have the controller respond to the event.

That way, if the control is changed to be the same as the model, then the change is internal, and no confirm is required, but if the control is changed by the user, then the control state differs from the model, and a confirm can be shown.

Pete Kirkham
Maybe have the controller handle the event is the way to go. My problem is that I have a menu view with some options that need to be communicated to a main content view.If the user checks something it should be communicated to the main view.But it can also happen that some process in the main view can trigger changes to those options on the menu view. And in this case, I do not want to trigger the events because otherwise i would send a useless and garbish message to the main view, because it was the view that triggered the change.
Jay