2

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!

Unhek
  • 93
  • 1
  • 9
  • Extract method from your Double Click event handler method, implement Click event and invoke that extracted method. – Marcin Zablocki Jul 22 '15 at 14:47
  • @Unhek This may help you. http://stackoverflow.com/questions/660554/how-to-automatically-select-all-text-on-focus-in-wpf-textbox – Abin Jul 22 '15 at 14:56

1 Answers1

1

Inside the single click event handler, do the following:

var newMouseEvent = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left) 
{ 
    RoutedEvent = Control.MouseDoubleClickEvent
};
myTextBox.RaiseEvent(newMouseEvent);
d.moncada
  • 16,900
  • 5
  • 53
  • 82