/// <summary> /// Occurs when <see cref="MaxValue" /> has changed. /// Sets <see cref="Value" /> to <see cref="MaxValueProperty" /> if the new max value is too large. /// </summary> /// <param name="sender"> /// The object of which the property has changed. /// </param> /// <param name="e"> /// The <see cref="DependencyPropertyChangedEventArgs" /> instance containing the event data. /// </param> private static void OnMaxValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { DragableTextBoxBase <ValueType> @this = (DragableTextBoxBase <ValueType>)sender; /*if (@this.Value.CompareTo(e.NewValue) > 0) { * @this.Value = (ValueType)e.NewValue; * }*/ }
private static void TextPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { DragableTextBoxBase <ValueType> instance = (DragableTextBoxBase <ValueType>)sender; ValueType newValue; if (instance.TryParseFromString((String)e.NewValue, out newValue)) { instance.value = newValue; } }