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.
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.