@ -15,6 +15,7 @@ namespace Microsoft.Windows.Controls
private List < DateTimeInfo > _d ateTimeInfoList = new List < DateTimeInfo > ( ) ;
private DateTimeInfo _ selectedDateTimeInfo ;
private bool _f ireSelectionChangedEvent = true ;
private bool _ processTextChanged = true ;
private DateTimeParser _d ateTimeParser ;
@ -55,10 +56,7 @@ namespace Microsoft.Windows.Controls
{
_d ateTimeParser . Format = GetFormatString ( newValue ) ;
InitializeDateTimeInfoListAndParseValue ( ) ;
//I forgot why I set the text here. I believe it had to deal with databinding to the format. Either way we need to make sure there is a value before we try to set the text.
if ( Value . HasValue )
Text = ConvertValueToText ( ) ;
UpdateTextFormatting ( ) ;
}
#endregion //Format
@ -86,6 +84,7 @@ namespace Microsoft.Windows.Controls
_d ateTimeParser . Format = newValue ;
InitializeDateTimeInfoListAndParseValue ( ) ;
UpdateTextFormatting ( ) ;
}
#endregion //FormatString
@ -178,6 +177,9 @@ namespace Microsoft.Windows.Controls
protected override void OnTextChanged ( string previousValue , string currentValue )
{
if ( ! _ processTextChanged )
return ;
//TODO: clean this up and make sure it doesn't fire recursively
if ( String . IsNullOrEmpty ( currentValue ) )
{
@ -558,6 +560,16 @@ namespace Microsoft.Windows.Controls
_f ireSelectionChangedEvent = true ;
}
private void UpdateTextFormatting ( )
{
_ processTextChanged = false ;
if ( Value . HasValue )
Text = ConvertValueToText ( ) ;
_ processTextChanged = true ;
}
#endregion //Methods
}
}