-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Align the Sender between the gestures when emit the events #28305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This file contains 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR aligns the sender returned by various gesture event handlers so that they consistently reference the view where the gesture is attached.
- Updated tests and UI code to validate that the sender is consistently the view regardless of the gesture type.
- Modified DragAndDrop event invocations in both DropGestureRecognizer and DragGestureRecognizer to use Parent ?? this (or the provided element) as the sender.
- Adjusted test UI elements to reflect these changes and ensure proper behavior across different gesture events.
Reviewed Changes
File | Description |
---|---|
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue17531.cs | Added test cases verifying that the sender is correctly set for tap and drag gestures. |
src/Controls/tests/TestCases.HostApp/Issues/Issue17531.xaml.cs | Updated event handlers to reflect the change in sender type for gesture events. |
src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs | Changed event invocations to use Parent ?? this, ensuring consistency for drop-related events. |
src/Controls/tests/TestCases.HostApp/Elements/DragAndDropBetweenLayouts.xaml.cs | Revised gesture-related casts and color brush usage to match the updated sender logic. |
src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs | Modified DragStarting event invocation to send the element parameter instead of this. |
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
rmarinho
approved these changes
Mar 24, 2025
rmarinho
approved these changes
Mar 25, 2025
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.
Description of Change
Depending on what kind of gesture is used, if you listen for the event associated with the gesture (for example DragStarting or Tapped) you either get the GestureRecognizer as the sender or the view in which the GestureRecognizer is inside of.
For example, if I listen for the Tapped event, the sender is going to be the view. If I listen for drag-related events (DragStarting, DragOver, DragLeave), I will get the DragGestureRecognizer.
This PR includes changes to return the View where the gesture is attached in the sender. Align the sender between the gestures when emit the events.
Issues Fixed
Fixes #17531