Reputation:
I'm constantly having to use TouchDown/TouchUp events here in my WPF project to detect a 'double-tap'; sometimes on a listbox, sometimes a button, sometimes a telerik control. How would I go about adding a DoubleTap event and event handler to these controls? Too big of a job?
Upvotes: 2
Views: 336
Reputation: 5605
You will have to use behaviors for this.This will include creating derived type from System.Windows.Interactivity.Behavior and override OnAttached method for TouchDown/TouchUp.
See WPF Tutorial | Behaviors and Introduction to Attached Behaviors in WPF for how to implement behaviors.
Upvotes: 0
Reputation: 13966
You could create a class that is constructed with a reference to the control and a delegate function. (Please forgive my not perfect syntax [if it isn't perfect], I am typing this from memory)
public class DoubleTap {
delegate void ActionFunction();
Control ReferencedControl;
public DoubleTap ( ref Control referencedControl , delegate actionFunction ) {
ActionFunction = actionFunction;
ReferencedControl = referencedControl;
// apply TouchDown and TouchUp event handlers to ReferencedControl
}
// Put your TouchDown and TouchUp functions for testing the double tap here
// when double tap tests as true then call ActionFunction();
}
Upvotes: 1