Distinguish UI change to variable from code-behind change
Posted
by Jay
on Stack Overflow
See other posts from Stack Overflow
or by Jay
Published on 2010-05-23T09:30:34Z
Indexed on
2010/05/23
9:40 UTC
Read the original article
Hit count: 286
wpf
|databinding
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.
© Stack Overflow or respective owner