OP here.
I realised after a while that it's the binding that keeps track of updating the TextBox
from the source (DataContext). So a possible path to take would be to call GetBindingExpression(TextProperty)
and work something out from that.
However, I solved it by overriding TextBoxBase.OnTextChanged
:
protected override void OnTextChanged(TextChangedEventArgs e)
{
base.OnTextChanged(e);
if (!IsFocused)
{
// Do stuff here
}
}
Since the control is not focused, the change must have been done programatically. This is not perfect since a programatical change might come when the TextBox
has focus, but it is good enough for me.