Skip to content

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

Merged
merged 6 commits into from
Mar 25, 2025
Merged

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Mar 11, 2025

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.

image

image

Issues Fixed

Fixes #17531

@jsuarezruiz jsuarezruiz added the area-gestures Gesture types label Mar 11, 2025
@Copilot Copilot AI review requested due to automatic review settings March 11, 2025 10:54
@jsuarezruiz jsuarezruiz requested a review from a team as a code owner March 11, 2025 10:54
@jsuarezruiz jsuarezruiz changed the title Align Align the sender between the gestures when emit the events Mar 11, 2025
@jsuarezruiz jsuarezruiz changed the title Align the sender between the gestures when emit the events Align the Sender between the gestures when emit the events Mar 11, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 rmarinho merged commit 6e6af5d into net10.0 Mar 25, 2025
126 of 128 checks passed
@rmarinho rmarinho deleted the fix-17531 branch March 25, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-gestures Gesture types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants