Thursday, September 27, 2007 1:43 PM
If you click into the adress bar of the internet explorer, the adress will get selected. Only the second click sets the caret into the mouse position.
I'd like to have this in my TextBox. I tried to override OnGotFocus and call SelectAll(), but this only works if the TextBox gets it focus by keyboard. If the TextBox is clicked by mouse, the text is selected for a split second, then it is deselected again and the caret is set.
Thursday, September 27, 2007 4:49 PM
This should give you a TextBox with behaviors similar to the IE address bar:Code Block
Here's the code behind:Code Block
privatevoid SelectAddress(object sender, RoutedEventArgs e)
TextBox tb = (senderas TextBox); if (tb != null)
privatevoid SelectivelyIgnoreMouseButton(object sender,
TextBox tb = (sender as TextBox);
if (tb != null)
e.Handled = true;
Friday, December 17, 2010 10:31 PMA little late on the thank you here, but THANK YOU! Exactly what I was looking for.
Thursday, August 25, 2011 7:10 PMWell done, man. Very helpful as I needed this.