A swipe motion occurs when a little finger try relocated over the screen in a horizontal or vertical path, and is often familiar with begin navigation through information.
The signal instances in this essay is obtained from the Swipe Gesture trial.
To manufacture a View identify a swipe gesture, make a SwipeGestureRecognizer instance, arranged the movement property to a SwipeDirection enumeration appreciate ( remaining , best , right up , or Down ), optionally arranged the Threshold house, deal with the Swiped celebration, and add this new motion recognizer with the GestureRecognizers range in the see. The next laws sample shows a SwipeGestureRecognizer attached with a BoxView :
Right here is the comparable C# signal:
The SwipeGestureRecognizer lessons comes with a limit land, that can be optionally set to a uint advantages that signifies minimal swipe range that needs to be gained for a swipe to get recognized, in device-independent products. The default property value this property was 100, which means any swipes which happen to be lower than 100 device-independent models are going to be overlooked.
Acknowledging the swipe movement
During the examples above, the movement belongings is scheduled to single a benefits through the SwipeDirection enumeration. But’s also feasible setting this house to multiple beliefs through the SwipeDirection enumeration, to ensure the Swiped celebration is fired as a result to a swipe much more than one movement. But the constraint usually an individual SwipeGestureRecognizer is only able to identify swipes that take place for a passing fancy axis. For that reason, swipes that happen regarding the horizontal axis is generally acknowledged by setting the movement land to remaining and Right :
Similarly, swipes that happen from the vertical axis could be acknowledged by establishing the Direction belongings to down and up :
On the other hand, a SwipeGestureRecognizer per swipe direction are intended to accept swipes atlanta divorce attorneys course:
This is actually the equivalent C# signal:
In the above instances, equivalent occasion handler responds toward Swiped show firing. However, each SwipeGestureRecognizer incidences may use another show handler if neccessary.
Addressing the swipe
An event handler when it comes down to Swiped event is shown inside next example:
The SwipedEventArgs is generally examined to discover the path of the swipe, with custom reasoning answering the swipe as required. The way on the swipe can be obtained through the movement land with the occasion arguments, that will be set to among beliefs on the SwipeDirection enumeration. Additionally, the event arguments also have a Parameter home which is set-to the worth of the CommandParameter belongings, if described.
Using directions
The SwipeGestureRecognizer course also includes Command and CommandParameter properties. These homes are typically found in solutions which use the Model-View-ViewModel (MVVM) routine. The order home defines the ICommand is invoked when a swipe motion is actually recognized, making use of the CommandParameter property identifying an object become passed towards ICommand. These code sample shows simple tips to join the demand property to an ICommand defined in view unit whoever case is scheduled because the webpage BindingContext :
The same XAML laws try:
SwipeCommand is actually a home of sort ICommand described inside the view product example which set because the page BindingContext . When a swipe motion is acknowledged, the perform method of the SwipeCommand object will likely be executed. The debate on perform method is the value of the CommandParameter property. For additional information about commands, look at demand user interface.
Generating a swipe bin
The SwipeContainer class, that is revealed inside appropriate code instance, was a general swipe acceptance course that be wrapped around a see to perform swipe gesture acceptance:
The SwipeContainer course brings SwipeGestureRecognizer objects regarding four swipe instructions, and connects Swipe occasion handlers. These show handlers invoke the Swipe event defined of the SwipeContainer .
These XAML signal sample reveals the SwipeContainer lessons covering a BoxView :
The subsequent signal sample demonstrates the way the SwipeContainer wraps a BoxView in a C# page:
Once the BoxView obtains a swipe gesture, the Swiped show when you look at the SwipeGestureRecognizer is actually fired. It is handled from the SwipeContainer course, which fires its Swipe celebration. This Swipe event was handled regarding webpage. The SwipedEventArgs may then end up being evaluated to look for the direction regarding the swipe, with custom reason responding to the swipe as needed.
دیدگاهتان را بنویسید
می خواهید در گفت و گو شرکت کنید؟خیالتان راحت باشد :)