From 5ff349863c2ddad62596f0dc89d24496e871863b Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Wed, 5 Jan 2011 02:43:11 +0000 Subject: [PATCH] DateTimeUpdown: fixed bug when user typed in date/time for the Value Property in xaml then clicking the up/down arrows without making a selection. --- .../DateTimeUpDown/DateTimeUpDown.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/DateTimeUpDown.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/DateTimeUpDown.cs index 6eedb5d7..0af73e15 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/DateTimeUpDown.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/DateTimeUpDown.cs @@ -59,14 +59,6 @@ namespace Microsoft.Windows.Controls InitializeDateTimeInfoList(); } - protected override void OnValueChanged(object oldValue, object newValue) - { - //whenever the value changes we need to parse out the value into out DateTimeInfo segments so we can keep track of the individual pieces - ParseValueIntoDateTimeInfo(); - - base.OnValueChanged(oldValue, newValue); - } - #endregion //Constructors #region Base Class Overrides @@ -85,6 +77,14 @@ namespace Microsoft.Windows.Controls base.OnPreviewKeyDown(e); } + protected override void OnValueChanged(object oldValue, object newValue) + { + //whenever the value changes we need to parse out the value into out DateTimeInfo segments so we can keep track of the individual pieces + ParseValueIntoDateTimeInfo(); + + base.OnValueChanged(oldValue, newValue); + } + protected override object OnCoerceValue(object value) { //if the user entered a string value to represent a date or time, we need to parse that string into a valid DatTime value @@ -378,6 +378,12 @@ namespace Microsoft.Windows.Controls { _fireSelectionChangedEvent = false; DateTimeInfo info = _selectedDateTimeInfo; + + //this only occurs when the user manually type in a value for the Value Property + if (info == null) + info = _dateTimeInfoList[0]; + + switch (info.Type) { case DateTimePart.Year: