Shahid Ur Rehman Shahid Ur Rehman - 8 months ago 43 Question

select the text of wpf textbox on click

I have implemented mentioned code to select the text of WPF textbox but it doesn't work.
the event which fires is the "PreviewMouseDown"

txtQuantity.SelectionStart = 0
txtQuantity.SelectionLength = txtQuantity.Text.Length


Assuming that you want to select the text of a textbox, with a click on the textbox itself, this will work.

Event PreviewMouseUp,




txtQuantity.Select(start, length)

The event PreviewMouseDown doesn't work because, the effect done by mouse down is overruled by the event PreviewMouseUp which makes the real "Click". Try holding the mouse button to see this effect.