Source: Windows Client
It doesn’t use code parsing or conversion from plain text to html or to rich text format. It simply uses the new Silverlight 4 RichTextBox control to display source code in the same rich text format as you copied it from the Visual Studio code editor. Probably the biggest advantage of this solution is that it works reliable for any programming language. C#, VB.NET, F#, C++, HTML, XAML, XML … what ever language you wish to highlight.
Several years back I posted a XML tokenizer for syntax highlighting. At the time I didn't post a complete app, since it was part of a larger project; if someone recently asked me for a little more context for the tokenizer so I put together a quickie Silverlight project showing how to use the tokenizer for syntax highlighting.
Alexei Prokudin has written an article on CodeProject where he has added Syntax Highlighting to a Textbox.
I have updated sources that contain new implementation for TextBlock's inline rendering. Now it is a bit faster with editing and scrolling 1000 lines. All other performance issues are related to Microsoft's Silverlight implementaion.