public override void OnApplyTemplate() { base.OnApplyTemplate(); valueBox = GetTemplateChild <SubmitTextBox>("PART_valueBox"); if (this.Value is double) { Binding b = BindingHelper.SetBinding( this, ValueProperty, valueBox, TextBox.TextProperty, converter: new DoubleToStringConverter()); //b.ValidationRules.Add(new DoubleRule()); } else { BindingHelper.SetBinding( this, ValueProperty, valueBox, TextBox.TextProperty); } if (!this.IsStable) { valueBox.Text = ""; } }
protected override void OnDispose() { if (valueBox == null) { return; } BindingOperations.ClearAllBindings(valueBox); valueBox = null; }