Skip to content
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

Binding Gesture Events #530

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/reference/gestures/pinchgesturerecognizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ image.GestureRecognizers.Add(new PinchGestureRecognizer());
The PinchGestureRegonizer raises a `Gestures.PinchEvent` when it detects the start of a pull gesture. When the pull ends, from the pointer being released or another gesture start, it raises a `Gestures.PinchEndedEvent`.
The `Scale` property in the args passed to the `Gestures.PinchEvent` event handler contains the relative size of the pinch since it started.

## Binding Events
After the PinchGestureRecognizer has been added to your control, you need to bind them in your code behind either through an inline handler or to an event function:
```csharp title='C#'
image.AddHandler(Gestures.PinchEvent, (s, e) => { });
image.AddHandler(Gestures.PinchEndedEvent, (s, e) => { });
```
```csharp title='C#'
image.AddHandler(Gestures.PinchEvent, Image_PinchGesture);
image.AddHandler(Gestures.PinchEndedEvent, Image_PinchGestureEnded);
...
private void Image_PinchGesture(object? sender, PinchGestureEventArgs e) { }
private void Image_PinchGestureEnded(object? sender, PinchGestureEndedEventArgs e) { }
```
If your event handles the gesture completely, you can mark the event as handled by setting:
```csharp title='C#'
e.Handled = true;
```

## More Information

:::info
Expand Down
20 changes: 19 additions & 1 deletion docs/reference/gestures/pullgesturerecognizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ border.GestureRecognizers.Add(new PullGestureRecognizer()
});
```

The PullGestureRegonizer raises a `Gestures.PullGestureEvent` when it detects the start of a pull gesture. When the pull ends, from the pointer being released or another gesture start, it raises a `Gestures.PullGestureEndedEvent`.
The PullGestureRecognizer raises a `Gestures.PullGestureEvent` when it detects the start of a pull gesture. When the pull ends, from the pointer being released or another gesture start, it raises a `Gestures.PullGestureEndedEvent`.

### PullDirection
This defines the direction of the pull. There are 4 available values;
Expand All @@ -35,6 +35,24 @@ This defines the direction of the pull. There are 4 available values;
* `PullDirection.LeftToRight` : Pull starts from the left edge and moves towards the right
* `PullDirection.RightToLeft` : Pull starts from the right edge and moves towards the top

## Binding Events
After the PullGestureRecognizer has been added to your control, you need to bind them in your code behind either through an inline handler or to an event function:
```csharp title='C#'
image.AddHandler(Gestures.PullGestureEvent, (s, e) => { });
image.AddHandler(Gestures.PullGestureEndedEvent, (s, e) => { });
```
```csharp title='C#'
image.AddHandler(Gestures.PullGestureEvent, Image_PullGesture);
image.AddHandler(Gestures.PullGestureEndedEvent, Image_PullGestureEnded);
...
private void Image_PullGesture(object? sender, PullGestureEventArgs e) { }
private void Image_PullGestureEnded(object? sender, PullGestureEndedEventArgs e) { }
```
If your event handles the gesture completely, you can mark the event as handled by setting:
```csharp title='C#'
e.Handled = true;
```

## Useful Properties

You will probably use these properties most often:
Expand Down
27 changes: 22 additions & 5 deletions docs/reference/gestures/scrollgesturerecognizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,31 @@ A ScrollGestureRecognizer can be attached to a control using the control's `Gest

```csharp title='C#'
image.GestureRecognizers.Add(new ScrollGestureRecognizer()
{
CanVerticallyScroll = true,
CanHorizontallyScroll = true,
});
{
CanVerticallyScroll = true,
CanHorizontallyScroll = true,
});
```

The ScrollGestureRegonizer raises a `Gestures.ScrollGestureEvent` when it detects the start of a scroll gesture. When the scroll ends, from the pointer being released or another gesture start, it raises a `Gestures.ScrollGestureEndedEvent`.
The ScrollGestureRecognizer raises a `Gestures.ScrollGestureEvent` when it detects the start of a scroll gesture. When the scroll ends, from the pointer being released or another gesture start, it raises a `Gestures.ScrollGestureEndedEvent`.

## Binding Events
After the ScrollGestureRecognizer has been added to your control, you need to bind them in your code behind either through an inline handler or to an event function:
```csharp title='C#'
image.AddHandler(Gestures.ScrollGestureEvent, (s, e) => { });
image.AddHandler(Gestures.ScrollGestureEndedEvent, (s, e) => { });
```
```csharp title='C#'
image.AddHandler(Gestures.ScrollGestureEvent, Image_ScrollGesture);
image.AddHandler(Gestures.ScrollGestureEndedEvent, Image_ScrollGestureEnded);
...
private void Image_ScrollGesture(object? sender, ScrollGestureEventArgs e) { }
private void Image_ScrollGestureEnded(object? sender, ScrollGestureEndedEventArgs e) { }
```
If your event handles the gesture completely, you can mark the event as handled by setting:
```csharp title='C#'
e.Handled = true;
```
## Useful Properties

You will probably use these properties most often:
Expand Down