Browse Source

Working on TimePicker

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
8974f98773
  1. 18
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeItem.cs
  2. 22
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimePicker.cs

18
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeItem.cs

@ -12,5 +12,23 @@ namespace Microsoft.Windows.Controls
Display = display;
Time = time;
}
#region Base Class Overrides
public override bool Equals(object obj)
{
var item = obj as TimeItem;
if (item != null)
return Time == item.Time;
else
return false;
}
public override int GetHashCode()
{
return Time.GetHashCode();
}
#endregion //Base Class Overrides
}
}

22
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimePicker.cs

@ -64,7 +64,7 @@ namespace Microsoft.Windows.Controls
SetValue(EndTimeProperty, value);
}
}
#endregion //EndTime
@ -181,7 +181,7 @@ namespace Microsoft.Windows.Controls
SetValue(StartTimeProperty, value);
}
}
#endregion //StartTime
@ -226,8 +226,22 @@ namespace Microsoft.Windows.Controls
protected virtual void OnValueChanged(DateTime? oldValue, DateTime? newValue)
{
// TODO: Add your property changed side-effects. Descendants can override as well.
}
//TODO: refactor this
if (newValue.HasValue)
{
var items = _timeListBox.ItemsSource;
foreach (TimeItem item in items)
{
if (item.Time == newValue.Value.TimeOfDay)
{
int index = _timeListBox.Items.IndexOf(item);
if (_timeListBox.SelectedIndex != index)
_timeListBox.SelectedIndex = index;
break;
}
}
}
}
#endregion //Value

Loading…
Cancel
Save