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: ResourceManager.GetConverter("DoubleToString")); 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; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); sourceBox = GetTemplateChild <SubmitTextBox>("PART_sourceBox"); sourceButton = GetTemplateChild <Button>("PART_sourceButton"); BindingHelper.SetBinding( this, ValueProperty, sourceBox, SubmitTextBox.TextProperty); sourceButton.Click += SourceButton_Click; }