Skip to content

Commit

Permalink
Merge pull request #530 from WSSC-AppDev/main
Browse files Browse the repository at this point in the history
Binding Gesture Events
  • Loading branch information
MikeCodesDotNET authored Dec 29, 2024
2 parents 21728be + e5eb4eb commit 7402378
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
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 left

## 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

0 comments on commit 7402378

Please sign in to comment.