Microsoft Word allows you to display grid lines on your document, as shown in this screen shot:
I am trying to create this same effect inside a WPF RichTextBox. What I did is I created my own control called MyRichTextBox which derives from RichTextBox, then I overrode the OnRender method, to simply draw a thick line to test it. The problem is, it looks like my line is being drawn under the text box itself. I can see a piece of it sticking out in the upper left corner. Anyone have any suggestions on how I can draw a line inside the actual text box? Here is my super simple code:
public class MyRichTextBox : RichTextBox
{
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
drawingContext.DrawLine(new Pen(Brushes.LimeGreen, 11.0),
new Point(1, 1), new Point(115, 115));
}
}

You could define a custom
ControlTemplateand override theOnRendermethod of theRichTextBox's internalScrollViewerelement:XAML: