protected override void OnRender(DrawingContext drawingContext)
{
TextView textView = this.TextView;
Size renderSize = this.RenderSize;
if (textView != null && textView.VisualLinesValid) {
var foreground = (Brush)GetValue(Control.ForegroundProperty);
foreach (VisualLine line in textView.VisualLines) {
int lineNumber = line.FirstDocumentLine.LineNumber;
FormattedText text = new FormattedText(
lineNumber.ToString(CultureInfo.CurrentCulture),
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface, emSize, foreground
);
drawingContext.DrawText(text, new Point(renderSize.Width - text.Width,
line.VisualTop - textView.VerticalOffset));
}
}
}