I've noticed many applications that expect you to do a lot of text editing will provide non-default behavior for double clicking text in that the application highlights text that it believes you're most likely trying to interact with.
As a quick example, this sentence behaves differently in different applications:
This is a "sample" sentence
If I type that in Notepad and double click the word 'sample' (ideally middle of the word, say, between the 'm' and 'p' of sample) then notepad highlights from the first quote to the space after the second quote inclusive. If that sentence is in a comment in Visual Studio and I double click in the same location, it highlights from the 's' to the 'e' of sample without highlighting the quotes.
How can I customize these highlighting behaviors in my own application? Is it different from winforms to WPF? I suppose I could hack my way to make it work on a double click event, but is there a more elegant/deliberate solution meant exclusively for this?