New to Telerik UI for WPFStart a free 30-day trial

Custom Gestures

Updated on Sep 15, 2025

With TouchManager you can create and use custom gestures using the basic events as TouchDown, TouchUp, TouchMove, etc. To implement a custom gesture you will need to create a gesture recognizer that defines the touch behavior and a gesture factory.

Gesture recognizer

The gesture recognizer should be a class that derives from the abstract GestureRecognizerBase class and handles the basic touch events translating them to specific gesture-related events.

GestureRecognizerBase exposes the Element property that holds the element the recognizer is assigned to and the HasGestureHandlers property that indicates if there are any attached handlers to the specific gesture.

The GestureRecognizerBase class exposes methods for the basic event handlers of TouchManager that are used for implementing the custom gesture.

  • OnTouchEnter: This method will be called when the TouchEnter event for the element is fired.
  • OnTouchDown: This method will be called when the TouchDown event for the element is fired.
  • OnTouchMove: This method will be called when a TouchMove event for the element is fired.
  • OnTouchUp: This method will be called when a TouchUp event for the element is fired.
  • OnTouchLeave: This method will be called when a TouchLeave event for the element is fired.

Example 1: Sample gesture recognizer

C#
	public class MyGestureRecognizer : GestureRecognizerBase
    {
		public override void OnTouchEnter(GestureRecognizerEventArgs args)
        {
        }
		
        public override void OnTouchDown(GestureRecognizerEventArgs args)
        {   
        }       

		public override void OnTouchMove(GestureRecognizerEventArgs args)
        {
        }
		
		public override void OnTouchUp(GestureRecognizerEventArgs args)
        {
        }
		
        public override void OnTouchLeave(GestureRecognizerEventArgs args)
        {
        }
    }

Gesture recognizer factory

The recognizer factory creates recognizers for the UI elements. In order to register a gesture recognizer you will need to implement a factory that creates the recognizer and defines its priority. The custom recognizer factory should implement the IGestureRecognizerFactory interface which exposes the following API:

  • Priority: A property of type int that defines the priority of the gesture.
  • CreateGestureRecognizer: A method that creates a new instance of a recognizer dedicated to the UI element.
  • RegisterGestureTransitions: A method that can be used to register the allowed gesture transitions.

Example 2: Sample gesture recognizer factory

C#
	public class MyGestureRecognizerFactory : IGestureRecognizerFactory
    {
        public GestureRecognizerBase CreateGestureRecognizer(System.Windows.UIElement element)
        {
            return new MyGestureRecognizer(element);
        }

        public int Priority
        {
            get
            {
                return 0;
            }
        }

        public void RegisterGestureTransitions()
        {
        }
    }

You can see how to implement a gesture in the Creating Custom Gesture help article.

See Also