MAUI Custom Swipe Control - With Left/Right Swipe Directions

131 Views Asked by At

We already had a implementation of swipe button(thanks to Alexandar , How to implement Swipe Button(with events) in MAUI App?). Out of this, we need to implement some other functionalities:-

  1. Right to Left swipe (need to set the direction of Swipe)
  2. Color change while swipe(Need to apply different color of the background while swipe)
  3. Keep the swipe button at the end(when swiping to the right/left side, button should be placed at the end of the control, current implementation is not like that.)
1

There are 1 best solutions below

7
On BEST ANSWER

Color change while swipe(Need to apply different color of the background while swipe)

You can change the Background color of the track bar in the process of swiping the control:GestureStatus.Running:

case GestureStatus.Running:

   <!--Omitted for Brevity-->           
   MyTrackBar.Background = Colors.Green;
   break;

Keep the swipe button at the end(when swiping to the right/left side, button should be placed at the end of the control, current implementation is not like that.)

If you want to the swipe button to reach at the end of the trackbar when finishing sliding it, you can set the first parameter: x of the method TranslateTo when GestureStatus.Completed:

case GestureStatus.Completed:
  <!--Omitted for Brevity-->
                   
MyThumb.TranslateTo(MyFillBar.Width-MyThumb.Width/2, 0, _animLength * 2, Easing.CubicIn),
                });

Output:

enter image description here