/// <summary> /// Default constructor. /// </summary> public QuantityWithUnitTextBox() { var binding = new Binding(); binding.Source = this; binding.Path = new PropertyPath("SelectedQuantity"); binding.Mode = BindingMode.TwoWay; binding.UpdateSourceTrigger = UpdateSourceTrigger.LostFocus; _converter = new QuantityWithUnitConverter(this, SelectedQuantityProperty); binding.Converter = _converter; binding.ValidationRules.Add(_converter); _converter.BindingExpression = this.SetBinding(TextBox.TextProperty, binding); this.TextChanged += new TextChangedEventHandler(QuantityWithUnitTextBox_TextChanged); }
/// <summary> /// Default constructor. /// </summary> public QuantityWithUnitTextBox() { var binding = new Binding { Source = this, Path = new PropertyPath(nameof(SelectedQuantity)), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.LostFocus }; _converter = new QuantityWithUnitConverter(this, SelectedQuantityProperty); binding.Converter = _converter; binding.ValidationRules.Add(_converter); _converter.BindingExpression = SetBinding(TextBox.TextProperty, binding); TextChanged += new TextChangedEventHandler(QuantityWithUnitTextBox_TextChanged); }