Unhek
Unhek

Reputation: 103

How to reroute click event to a double click?

I'm trying to reroute a Click event to act like a Double Click instead. For example if I double click a TextBox it will select all the text so you can edit, I want a single click to do the same.

Is it possible to reroute events like this and if so how does one do so? Thanks!

Upvotes: 2

Views: 145

Answers (1)

d.moncada
d.moncada

Reputation: 17392

Inside the single click event handler, do the following:

var newMouseEvent = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left) 
{ 
    RoutedEvent = Control.MouseDoubleClickEvent
};
myTextBox.RaiseEvent(newMouseEvent);

Upvotes: 1

Related Questions