I found an example, how to show the LineNumbers from a RichTextBox in Windows Forms.
http://www.codeproject.com/Articles/38858/Line-Numbers-for-RichText-Control
The best example you can find is in AvalonEdit. There is lot more anyway that just line numbering, but you can study how it is done, code is very clear. A staring point to see what we are talking about can be this CodeProject article.