How do I repetitively perform an action when the mouse left button is pressed and held down in WPF?
The following event handler for the UIElement.PreviewMouseLeftButtonDown event does not get the job done:
private void BaseButtonRight_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// keep performing action while mouse left button is pressed.
// Checking e.ButtonState works only for one click
}
Execution does not even get into the while loop and handler is called when the left mouse button is released!
Best Answer
Why not use a RepeatButton?
http://msdn.microsoft.com/en-us/library/ms746649(v=vs.85).aspx