A swipe motion occurs when a thumb is relocated throughout the display screen in a horizontal or straight course, and is also usually always begin routing through information.

A swipe motion occurs when a thumb is relocated throughout the display screen in a horizontal or straight course, and is also usually always begin routing through information.

The laws examples in this article are taken from the Swipe motion sample.

Which will make a View acknowledge a swipe gesture, make a SwipeGestureRecognizer instance, set the movement belongings to a SwipeDirection enumeration price ( kept , correct , Up , or Down ), optionally arranged the Threshold homes, deal with the Swiped event, and incorporate the motion recognizer on the GestureRecognizers range from the view. Listed here code instance shows a SwipeGestureRecognizer mounted on a BoxView :

Right here is the equivalent C# rule:

The SwipeGestureRecognizer course also contains a limit homes, that can be optionally set-to a uint price that symbolizes minimal swipe point waplog team that must be gained for a swipe getting known, in device-independent devices. The standard worth of this property was 100, which means that any swipes which happen to be not as much as 100 device-independent devices is ignored.

Recognizing the swipe way

When you look at the advice above, the course homes is scheduled to single an appreciate through the SwipeDirection enumeration. But’s also possible to put this land to several prices through the SwipeDirection enumeration, to ensure the Swiped show try fired as a result to a swipe in more than one path. But the restriction is the fact that an individual SwipeGestureRecognizer can just only know swipes that take place on the same axis. Therefore, swipes that happen on the horizontal axis is generally acknowledged by establishing the movement land to Left and Right :

Equally, swipes that happen from the vertical axis is generally identified by placing the course home to top to bottom :

Instead, a SwipeGestureRecognizer for every swipe course may be intended to accept swipes in almost every movement:

This is actually the equivalent C# laws:

In above instances, exactly the same occasion handler reacts towards the Swiped show shooting. But each SwipeGestureRecognizer incidences can use a new show handler if needed.

Responding to the swipe

A meeting handler the Swiped show is shown for the preceding example:

The SwipedEventArgs are evaluated to discover the path of the swipe, with custom reason replying to the swipe as required. The direction associated with the swipe can be obtained from the movement property of the celebration arguments, that is set-to among principles with the SwipeDirection enumeration. In addition, the big event arguments likewise have a Parameter belongings that’ll be set to the worth of the CommandParameter home, if defined.

Making use of commands

The SwipeGestureRecognizer course also includes Command and CommandParameter characteristics. These residential properties are usually included in software which use the Model-View-ViewModel (MVVM) design. The Command residential property defines the ICommand to-be invoked whenever a swipe gesture try recognized, aided by the CommandParameter homes defining an object are passed into the ICommand. Listed here signal example demonstrates just how to join the Command belongings to an ICommand defined for the see unit whoever incidences is placed given that page BindingContext :

Very same XAML code are:

SwipeCommand try a residential property of sort ICommand described for the view unit case that is put since web page BindingContext . When a swipe motion try recognized, the perform method of the SwipeCommand object will be accomplished. The argument for the Execute technique is the worth of the CommandParameter home. For additional information about directions, look at demand user interface.

Producing a swipe container

The SwipeContainer lessons, basically found from inside the appropriate rule sample, was a generalized swipe popularity class that be wrapped around a see to perform swipe gesture identification:

The SwipeContainer class creates SwipeGestureRecognizer stuff for all four swipe directions, and attaches Swipe show handlers. These event handlers invoke the Swipe celebration explained of the SwipeContainer .

The following XAML rule instance reveals the SwipeContainer class wrapping a BoxView :

Listed here rule sample demonstrates how SwipeContainer wraps a BoxView in a C# page:

After BoxView gets a swipe motion, the Swiped event during the SwipeGestureRecognizer is actually discharged. This might be handled from the SwipeContainer course, which fires a unique Swipe occasion. This Swipe celebration is actually taken care of throughout the page. The SwipedEventArgs may then end up being evaluated to discover the course of this swipe, with custom reasoning addressing the swipe as needed.

[contact-form-7 404 "Not Found"]
0 0 vote
Đánh giá
Theo dõi
Thông báo khi
0 Bình luận
Inline Feedbacks
Tất cả bình luận