WPF bindings do not use your DocumentText
property; instead they access the underlying value of the dependency property directly.
Your OnTextChanged
method doesn't actually change the value of the underlying dependency property. You will need to copy the value from base.Text
into the dependency property on every change:
protected override void OnTextChanged(EventArgs e)
{
SetCurrentValue(DocumentTextProperty, base.Text);
base.OnTextChanged(e);
}
This issue would be easier to see if you followed the correct pattern for implementing DependencyProperty
: The DocumentText
property should use the GetValue
/SetValue
methods, and not access a different backing store.