Invoke button commands through the native click flow - #355
Merged
Merged
Conversation
wieslawsoltes
marked this pull request as ready for review
July 14, 2026 22:18
This was referenced Aug 21, 2026
This was referenced Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clickevent, disabled-state,CanExecute, and flyout semanticsProblem
InvokeButtonClickActionpreviously calledbutton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)). That only raised the routed event. It did not callButton.OnClick(), so Avalonia never reached the command execution portion of its button activation pipeline.A button with
Command="{Binding ...}"therefore appeared to receive a click event while its command was never invoked, which is the failure reported in #322.Root cause
Avalonia's
Button.OnClick()performs more work than raisingClickEvent:ClickeventCommandwithCommandParameterRaising the routed event directly bypassed steps 1, 2, and 4.
Changes
ButtonAutomationPeer.Invoke()to enter Avalonia's supported button invocation pathfalsewithout invoking an effectively disabled targetTests
Added headless coverage proving that:
Clickevent is raised and the bound command receives the exact configured parameterClickevent suppresses command execution, matching Avalonia's native orderingClickor execute their commandValidation
dotnet test tests/Xaml.Behaviors.Interactions.UnitTests/Xaml.Behaviors.Interactions.UnitTests.csproj --filter 'FullyQualifiedName~InvokeButtonClickActionTests' --no-restoredotnet test tests/Xaml.Behaviors.Interactions.UnitTests/Xaml.Behaviors.Interactions.UnitTests.csproj --no-restoregit diff --checkCloses #322