diff --git a/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs b/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs index 157a2f4..775d66b 100644 --- a/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs +++ b/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs @@ -457,5 +457,32 @@ public class DateRangePicker : DatePickerBase, IClearControl break; } } - + + protected override void OnGotFocus(GotFocusEventArgs e) + { + base.OnGotFocus(e); + FocusChanged(IsKeyboardFocusWithin); + } + + private bool _isFocused; + private void FocusChanged(bool hasFocus) + { + // The OnGotFocus & OnLostFocus are asynchronously and cannot + // reliably tell you that have the focus. All they do is let you + // know that the focus changed sometime in the past. To determine + // if you currently have the focus you need to do consult the + // FocusManager. + + bool wasFocused = _isFocused; + _isFocused = hasFocus; + + if (hasFocus) + { + + if (!wasFocused && _start == null) + { + _start = true; + } + } + } } \ No newline at end of file