Browse Source

DateTimeUpDown/DateTimePicker: fixed applying a custom format when the FormatString is defined first in XAML.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
d8f5f1f0f1
  1. 20
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs

20
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs

@ -15,6 +15,7 @@ namespace Microsoft.Windows.Controls
private List<DateTimeInfo> _dateTimeInfoList = new List<DateTimeInfo>();
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
}
}

Loading…
Cancel
Save