Skip to content

Commit 7402378

Browse files
Merge pull request #530 from WSSC-AppDev/main
Binding Gesture Events
2 parents 21728be + e5eb4eb commit 7402378

File tree

3 files changed

+59
-6
lines changed

3 files changed

+59
-6
lines changed

docs/reference/gestures/pinchgesturerecognizer.md

+18
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ image.GestureRecognizers.Add(new PinchGestureRecognizer());
2626
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`.
2727
The `Scale` property in the args passed to the `Gestures.PinchEvent` event handler contains the relative size of the pinch since it started.
2828

29+
## Binding Events
30+
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:
31+
```csharp title='C#'
32+
image.AddHandler(Gestures.PinchEvent, (s, e) => { });
33+
image.AddHandler(Gestures.PinchEndedEvent, (s, e) => { });
34+
```
35+
```csharp title='C#'
36+
image.AddHandler(Gestures.PinchEvent, Image_PinchGesture);
37+
image.AddHandler(Gestures.PinchEndedEvent, Image_PinchGestureEnded);
38+
...
39+
private void Image_PinchGesture(object? sender, PinchGestureEventArgs e) { }
40+
private void Image_PinchGestureEnded(object? sender, PinchGestureEndedEventArgs e) { }
41+
```
42+
If your event handles the gesture completely, you can mark the event as handled by setting:
43+
```csharp title='C#'
44+
e.Handled = true;
45+
```
46+
2947
## More Information
3048

3149
:::info

docs/reference/gestures/pullgesturerecognizer.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ border.GestureRecognizers.Add(new PullGestureRecognizer()
2626
});
2727
```
2828

29-
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`.
29+
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`.
3030

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

38+
## Binding Events
39+
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:
40+
```csharp title='C#'
41+
image.AddHandler(Gestures.PullGestureEvent, (s, e) => { });
42+
image.AddHandler(Gestures.PullGestureEndedEvent, (s, e) => { });
43+
```
44+
```csharp title='C#'
45+
image.AddHandler(Gestures.PullGestureEvent, Image_PullGesture);
46+
image.AddHandler(Gestures.PullGestureEndedEvent, Image_PullGestureEnded);
47+
...
48+
private void Image_PullGesture(object? sender, PullGestureEventArgs e) { }
49+
private void Image_PullGestureEnded(object? sender, PullGestureEndedEventArgs e) { }
50+
```
51+
If your event handles the gesture completely, you can mark the event as handled by setting:
52+
```csharp title='C#'
53+
e.Handled = true;
54+
```
55+
3856
## Useful Properties
3957

4058
You will probably use these properties most often:

docs/reference/gestures/scrollgesturerecognizer.md

+22-5
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,31 @@ A ScrollGestureRecognizer can be attached to a control using the control's `Gest
2222

2323
```csharp title='C#'
2424
image.GestureRecognizers.Add(new ScrollGestureRecognizer()
25-
{
26-
CanVerticallyScroll = true,
27-
CanHorizontallyScroll = true,
28-
});
25+
{
26+
CanVerticallyScroll = true,
27+
CanHorizontallyScroll = true,
28+
});
2929
```
3030

31-
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`.
31+
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`.
3232

33+
## Binding Events
34+
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:
35+
```csharp title='C#'
36+
image.AddHandler(Gestures.ScrollGestureEvent, (s, e) => { });
37+
image.AddHandler(Gestures.ScrollGestureEndedEvent, (s, e) => { });
38+
```
39+
```csharp title='C#'
40+
image.AddHandler(Gestures.ScrollGestureEvent, Image_ScrollGesture);
41+
image.AddHandler(Gestures.ScrollGestureEndedEvent, Image_ScrollGestureEnded);
42+
...
43+
private void Image_ScrollGesture(object? sender, ScrollGestureEventArgs e) { }
44+
private void Image_ScrollGestureEnded(object? sender, ScrollGestureEndedEventArgs e) { }
45+
```
46+
If your event handles the gesture completely, you can mark the event as handled by setting:
47+
```csharp title='C#'
48+
e.Handled = true;
49+
```
3350
## Useful Properties
3451

3552
You will probably use these properties most often:

0 commit comments

Comments
 (0)