using System.Windows.Controls;
using System.Windows;
using System.Windows.Interactivity;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using System.Windows.Data;

namespace WpfApplication1
{
    public class PropertyChangedUpdateTriggerBehavior : Behavior<TextBox>
    {
        protected override void OnAttached()
        {
            this.AssociatedObject.TextChanged += OnTextBoxTextChanged;
        }

        void OnTextBoxTextChanged(object sender, TextChangedEventArgs e)
        {
            var bindingExpression = this.AssociatedObject.ReadLocalValue(TextBox.TextProperty) as BindingExpression;
            if (bindingExpression != null)
            {
                bindingExpression.UpdateSource();
            }
        }

        protected override void OnDetaching()
        {
            this.AssociatedObject.TextChanged -= OnTextBoxTextChanged;
        }
    }
}