@ -73,10 +73,12 @@ namespace Microsoft.Windows.Controls.Primitives
protected virtual void OnValueChanged ( T oldValue , T newValue )
protected virtual void OnValueChanged ( T oldValue , T newValue )
{
{
Coerc eValue( newValue ) ;
Validat eValue( newValue ) ;
SyncTextAndValueProperties ( ValueProperty , string . Empty ) ;
SyncTextAndValueProperties ( ValueProperty , string . Empty ) ;
SetValidSpinDirection ( ) ;
RoutedPropertyChangedEventArgs < object > args = new RoutedPropertyChangedEventArgs < object > ( oldValue , newValue ) ;
RoutedPropertyChangedEventArgs < object > args = new RoutedPropertyChangedEventArgs < object > ( oldValue , newValue ) ;
args . RoutedEvent = ValueChangedEvent ;
args . RoutedEvent = ValueChangedEvent ;
RaiseEvent ( args ) ;
RaiseEvent ( args ) ;
@ -109,6 +111,8 @@ namespace Microsoft.Windows.Controls.Primitives
TextBox = GetTemplateChild ( ElementTextName ) as TextBox ;
TextBox = GetTemplateChild ( ElementTextName ) as TextBox ;
Spinner = GetTemplateChild ( ElementSpinnerName ) as Spinner ;
Spinner = GetTemplateChild ( ElementSpinnerName ) as Spinner ;
Spinner . Spin + = OnSpinnerSpin ;
Spinner . Spin + = OnSpinnerSpin ;
SetValidSpinDirection ( ) ;
}
}
protected override void OnGotFocus ( RoutedEventArgs e )
protected override void OnGotFocus ( RoutedEventArgs e )
@ -256,12 +260,11 @@ namespace Microsoft.Windows.Controls.Primitives
}
}
#region Abstract
#region Abstract
/// <summary>
/// <summary>
/// Coerces the value.
/// Coerces the value.
/// </summary>
/// </summary>
protected abstract void CoerceValue ( T value ) ;
protected abstract T CoerceValue ( T value ) ;
/// <summary>
/// <summary>
/// Converts the formatted text to a value.
/// Converts the formatted text to a value.
@ -284,6 +287,17 @@ namespace Microsoft.Windows.Controls.Primitives
/// </summary>
/// </summary>
protected abstract void OnDecrement ( ) ;
protected abstract void OnDecrement ( ) ;
/// <summary>
/// Sets the valid spin directions.
/// </summary>
protected abstract void SetValidSpinDirection ( ) ;
/// <summary>
/// Validates the value and keeps it between the Min and Max values.
/// </summary>
/// <param name="value">The value.</param>
protected abstract void ValidateValue ( T value ) ;
#endregion //Abstract
#endregion //Abstract
#endregion //Methods
#endregion //Methods