Hi folks,
I want to control the status of a TextBox bound to some other properties with Mode=TwoWay. To do this I have to distinguish between text changes in the TextBox coming from the bound source an from other sources (keyboard and the like). To do this I added an Event Handler to the TextBox.Text property using DependencyPropertyDescription.AddValueChanged. The callback works as expected.
In the callback I try to use the BindingExpressionBase.IsDirty property. The debugger shows this property in its "Locals" display and also with "? .." in the immediate window. This is the output from the immediate window:
? dataBoxBinding
{System.Windows.Data.BindingExpression}
[System.Windows.Data.BindingExpression]: {System.Windows.Data.BindingExpression}
base {System.Windows.Expression}: {System.Windows.Data.BindingExpression}
BindingGroup: null
HasError: false
HasValidationError: false
IsDirty: false
ParentBindingBase: {System.Windows.Data.Binding}
Status: Active
Target: {ProductManagement.ViewModels.DataBox: Szenario (A)}
TargetProperty: {Text}
ValidationError: null
ValidationErrors: null
This property changes to true, if TextBox.Text is changed with the keyboard or from the clipboard. It changes to false when it is set by binding with data from the source. Would be perfect for me.
Now this is my problem:
When trying to implement code in C#, the compiler flags IsDirty as ".. has no definition in the context of BindingExpresssionBase". The appropriate namespace is loaded.
BindingExpressionBase dataBoxBinding = BindingOperations.GetBindingExpressionBase(this, DataBox.TextProperty); if (dataBoxBinding.IsDirty) return;
Your help is very welcome.
Thanks in advance.
Regards Uwe