Browse Source

Use new RoutedEvent registration

pull/7422/head
Max Katz 5 years ago
parent
commit
f10ced11ee
  1. 9
      src/Avalonia.Controls/SplitButton/SplitButton.cs

9
src/Avalonia.Controls/SplitButton/SplitButton.cs

@ -30,7 +30,8 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Defines the <see cref="Click"/> event. /// Defines the <see cref="Click"/> event.
/// </summary> /// </summary>
public static readonly RoutedEvent<RoutedEventArgs> ClickEvent = Button.ClickEvent; public static readonly RoutedEvent<RoutedEventArgs> ClickEvent =
RoutedEvent.Register<SplitButton, RoutedEventArgs>(nameof(Click), RoutingStrategies.Bubble);
/// <summary> /// <summary>
/// Defines the <see cref="Command"/> property. /// Defines the <see cref="Command"/> property.
@ -384,7 +385,7 @@ namespace Avalonia.Controls
// Note: It is not currently required to check enabled status; however, this is a failsafe // Note: It is not currently required to check enabled status; however, this is a failsafe
if (IsEffectivelyEnabled) if (IsEffectivelyEnabled)
{ {
var eventArgs = new RoutedEventArgs(Button.ClickEvent); var eventArgs = new RoutedEventArgs(ClickEvent);
RaiseEvent(eventArgs); RaiseEvent(eventArgs);
if (!eventArgs.Handled && Command?.CanExecute(CommandParameter) == true) if (!eventArgs.Handled && Command?.CanExecute(CommandParameter) == true)
@ -417,6 +418,8 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
private void PrimaryButton_Click(object? sender, RoutedEventArgs e) private void PrimaryButton_Click(object? sender, RoutedEventArgs e)
{ {
// Handle internal button click, so it won't bubble outside together with SplitButton.ClickEvent.
e.Handled = true;
OnClickPrimary(e); OnClickPrimary(e);
} }
@ -425,6 +428,8 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
private void SecondaryButton_Click(object? sender, RoutedEventArgs e) private void SecondaryButton_Click(object? sender, RoutedEventArgs e)
{ {
// Handle internal button click, so it won't bubble outside.
e.Handled = true;
OnClickSecondary(e); OnClickSecondary(e);
} }

Loading…
Cancel
Save