diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index a2efc7fba0..a7a4759182 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -85,8 +85,8 @@ namespace Avalonia.Controls /// /// Defines the property /// - public static readonly StyledProperty FlyoutProperty = - AvaloniaProperty.Register(nameof(Flyout)); + public static readonly StyledProperty FlyoutProperty = + AvaloniaProperty.Register(nameof(Flyout)); private ICommand? _command; private bool _commandCanExecute = true; @@ -186,7 +186,7 @@ namespace Avalonia.Controls /// /// Gets or sets the Flyout that should be shown with this button. /// - public FlyoutBase Flyout + public FlyoutBase? Flyout { get => GetValue(FlyoutProperty); set => SetValue(FlyoutProperty, value); diff --git a/src/Avalonia.Controls/SplitButton/SplitButton.cs b/src/Avalonia.Controls/SplitButton/SplitButton.cs index a85d34537f..8e32d46820 100644 --- a/src/Avalonia.Controls/SplitButton/SplitButton.cs +++ b/src/Avalonia.Controls/SplitButton/SplitButton.cs @@ -35,7 +35,7 @@ namespace Avalonia.Controls /// /// Defines the property. /// - public static readonly DirectProperty CommandProperty = + public static readonly DirectProperty CommandProperty = Button.CommandProperty.AddOwner( splitButton => splitButton.Command, (splitButton, command) => splitButton.Command = command); @@ -43,25 +43,25 @@ namespace Avalonia.Controls /// /// Defines the property. /// - public static readonly StyledProperty CommandParameterProperty = + public static readonly StyledProperty CommandParameterProperty = Button.CommandParameterProperty.AddOwner(); /// /// Defines the property /// - public static readonly StyledProperty FlyoutProperty = + public static readonly StyledProperty FlyoutProperty = Button.FlyoutProperty.AddOwner(); - private ICommand _Command; + private ICommand? _Command; - private Button _primaryButton = null; - private Button _secondaryButton = null; + private Button? _primaryButton = null; + private Button? _secondaryButton = null; private bool _commandCanExecute = true; private bool _isAttachedToLogicalTree = false; private bool _isFlyoutOpen = false; - private IDisposable _flyoutPropertyChangedDisposable; + private IDisposable? _flyoutPropertyChangedDisposable; //////////////////////////////////////////////////////////////////////// // Constructor / Destructors @@ -81,7 +81,7 @@ namespace Avalonia.Controls /// /// Gets or sets the invoked when the primary part is pressed. /// - public ICommand Command + public ICommand? Command { get => _Command; set => SetAndRaise(CommandProperty, ref _Command, value); @@ -90,7 +90,7 @@ namespace Avalonia.Controls /// /// Gets or sets a parameter to be passed to the . /// - public object CommandParameter + public object? CommandParameter { get => GetValue(CommandParameterProperty); set => SetValue(CommandParameterProperty, value); @@ -99,7 +99,7 @@ namespace Avalonia.Controls /// /// Gets or sets the that is shown when the secondary part is pressed. /// - public FlyoutBase Flyout + public FlyoutBase? Flyout { get => GetValue(FlyoutProperty); set => SetValue(FlyoutProperty, value); @@ -126,7 +126,7 @@ namespace Avalonia.Controls void ICommandSource.CanExecuteChanged(object sender, EventArgs e) => this.CanExecuteChanged(sender, e); /// - private void CanExecuteChanged(object sender, EventArgs e) + private void CanExecuteChanged(object? sender, EventArgs e) { var canExecute = Command == null || Command.CanExecute(CommandParameter); @@ -172,7 +172,7 @@ namespace Avalonia.Controls /// Registers all flyout events. /// /// The flyout to connect events to. - private void RegisterFlyoutEvents(FlyoutBase flyout) + private void RegisterFlyoutEvents(FlyoutBase? flyout) { if (flyout != null) { @@ -187,7 +187,7 @@ namespace Avalonia.Controls /// Explicitly unregisters all flyout events. /// /// The flyout to disconnect events from. - private void UnregisterFlyoutEvents(FlyoutBase flyout) + private void UnregisterFlyoutEvents(FlyoutBase? flyout) { if (flyout != null) { @@ -379,7 +379,7 @@ namespace Avalonia.Controls /// Invokes the event when the primary button part is clicked. /// /// The event args from the internal Click event. - protected virtual void OnClickPrimary(RoutedEventArgs e) + protected virtual void OnClickPrimary(RoutedEventArgs? e) { // Note: It is not currently required to check enabled status; however, this is a failsafe if (IsEffectivelyEnabled) @@ -399,7 +399,7 @@ namespace Avalonia.Controls /// Invoked when the secondary button part is clicked. /// /// The event args from the internal Click event. - protected virtual void OnClickSecondary(RoutedEventArgs e) + protected virtual void OnClickSecondary(RoutedEventArgs? e) { // Note: It is not currently required to check enabled status; however, this is a failsafe if (IsEffectivelyEnabled) @@ -415,7 +415,7 @@ namespace Avalonia.Controls /// /// Event handler for when the internal primary button part is pressed. /// - private void PrimaryButton_Click(object sender, RoutedEventArgs e) + private void PrimaryButton_Click(object? sender, RoutedEventArgs e) { OnClickPrimary(e); } @@ -423,7 +423,7 @@ namespace Avalonia.Controls /// /// Event handler for when the internal secondary button part is pressed. /// - private void SecondaryButton_Click(object sender, RoutedEventArgs e) + private void SecondaryButton_Click(object? sender, RoutedEventArgs e) { OnClickSecondary(e); } @@ -439,7 +439,7 @@ namespace Avalonia.Controls /// /// Event handler for when the split button's flyout is opened. /// - private void Flyout_Opened(object sender, EventArgs e) + private void Flyout_Opened(object? sender, EventArgs e) { var flyout = sender as FlyoutBase; @@ -459,7 +459,7 @@ namespace Avalonia.Controls /// /// Event handler for when the split button's flyout is closed. /// - private void Flyout_Closed(object sender, EventArgs e) + private void Flyout_Closed(object? sender, EventArgs e) { var flyout = sender as FlyoutBase; diff --git a/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs b/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs index c926250105..879c1aa6e1 100644 --- a/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs +++ b/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs @@ -115,7 +115,7 @@ namespace Avalonia.Controls } /// - protected override void OnClickPrimary(RoutedEventArgs e) + protected override void OnClickPrimary(RoutedEventArgs? e) { Toggle();