A core feature of this app is the pan gesture. A pan gesture is when a user presses on the control and moves it around the screen. We will also add a random rotation to the Swiper control to make it look like there are photos in a stack when we add multiple images.
We start by adding some fields to the SwiperControl class, as follows:
- Open the SwiperControl.xaml.cs file.
- Add the following fields in the code to the class:
private readonly double _initialRotation;
private static readonly Random _random = new Random();
The first field, _initialRotation, stores the initial rotation of the image. We will set this in the constructor. The second field is a static field containing a Random object. As you might remember, it's better to create one static random object to make sure multiple random objects don't get created with the same seed. The seed is based on time, so if we create objects too close in time to each other, they get the same random sequence...