This is a WPF control I just put on
CodePlex
that implements the basic functionality
for a source code editor.
You define it in the XAML with something like this (of course after you put the assembly com.bodurov.WpfControls.SourceCodeEditor.dll in your bin folder):