Skip to content

Commit

Permalink
Fix #60
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Apr 14, 2020
1 parent 8f0f49e commit 240e043
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ModernWpf.Controls/ToggleSwitch/ToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public ToggleSwitch()
IsEnabledChanged += OnIsEnabledChanged;
}

public static readonly RoutedEvent ToggledEvent = EventManager.RegisterRoutedEvent(nameof(Toggled), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ToggleSwitch));

public event RoutedEventHandler Toggled
{
add { AddHandler(ToggledEvent, value); }
remove { RemoveHandler(ToggledEvent, value); }
}

#region Header

public object Header
Expand Down Expand Up @@ -261,8 +269,6 @@ public CornerRadius CornerRadius

private Thumb SwitchThumb { get; set; }

public event RoutedEventHandler Toggled;

public override void OnApplyTemplate()
{
if (SwitchKnobBounds != null &&
Expand Down Expand Up @@ -311,7 +317,7 @@ public override void OnApplyTemplate()

protected virtual void OnToggled()
{
Toggled?.Invoke(this, new RoutedEventArgs());
RaiseEvent(new RoutedEventArgs(ToggledEvent));
}

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
Expand Down

0 comments on commit 240e043

Please sign in to comment.