, MacOs.
MacOs keyup ( , Firefox).
In the accepted answer, this becomes a big problem because UpdateSourceTrigger is set to Explicitly, but the event never fires. Consequence: you never update the binding.
However, the TextChanged event always fires. listen to this and all is well :)
Here is my version:
public class AutoUpdateTextBox : TextBox
{
public AutoUpdateTextBox()
{
TextChanged += OnTextChanged;
}
private void OnTextChanged(object sender, TextChangedEventArgs e)
{
this.UpdateBinding(TextProperty);
}
}
And UpdateBinding ExtensionMethod:
public static void UpdateBinding(this FrameworkElement element,
DependencyProperty dependencyProperty)
{
var bindingExpression = element.GetBindingExpression(dependencyProperty);
if (bindingExpression != null)
bindingExpression.UpdateSource();
}
source
share