diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs index 7b366bc0..461a2779 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs @@ -15,6 +15,7 @@ namespace Microsoft.Windows.Controls private List _dateTimeInfoList = new List(); private DateTimeInfo _selectedDateTimeInfo; private bool _fireSelectionChangedEvent = true; + private bool _processTextChanged = true; private DateTimeParser _dateTimeParser; @@ -55,10 +56,7 @@ namespace Microsoft.Windows.Controls { _dateTimeParser.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 _dateTimeParser.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 _fireSelectionChangedEvent = true; } + private void UpdateTextFormatting() + { + _processTextChanged = false; + + if (Value.HasValue) + Text = ConvertValueToText(); + + _processTextChanged = true; + } + #endregion //Methods } }