Skip to content

Commit

Permalink
(MahAppsGH-3746) Respect IsEnabledProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed May 4, 2020
1 parent 39f6cf8 commit 44d032b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ static DateTimePicker()

public DateTimePicker()
{
this.SetCurrentValue(DisplayDateProperty, DateTime.Today);
}

/// <inheritdoc />
Expand Down
11 changes: 10 additions & 1 deletion src/MahApps.Metro/Controls/TimePicker/TimePickerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ private static void OnIsDropDownOpenChanged(DependencyObject d, DependencyProper
}
}

private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TimePickerBase tp)
{
tp.CoerceValue(IsDropDownOpenProperty);
}
}

/// <summary>
/// This method is invoked when the <see cref="IsDropDownOpenProperty"/> changes.
/// </summary>
Expand Down Expand Up @@ -228,10 +236,11 @@ protected virtual void FocusElementAfterIsDropDownOpenChanged()

static TimePickerBase()
{
EventManager.RegisterClassHandler(typeof(TimePickerBase), UIElement.GotFocusEvent, new RoutedEventHandler(OnGotFocus));
DefaultStyleKeyProperty.OverrideMetadata(typeof(TimePickerBase), new FrameworkPropertyMetadata(typeof(TimePickerBase)));
EventManager.RegisterClassHandler(typeof(TimePickerBase), UIElement.GotFocusEvent, new RoutedEventHandler(OnGotFocus));
VerticalContentAlignmentProperty.OverrideMetadata(typeof(TimePickerBase), new FrameworkPropertyMetadata(VerticalAlignment.Center));
LanguageProperty.OverrideMetadata(typeof(TimePickerBase), new FrameworkPropertyMetadata(OnLanguageChanged));
IsEnabledProperty.OverrideMetadata(typeof(DatePicker), new UIPropertyMetadata(new PropertyChangedCallback(OnIsEnabledChanged)));
}

protected TimePickerBase()
Expand Down

0 comments on commit 44d032b

Please sign in to comment.