Skip to content

Line Numbers

Pavel edited this page Oct 21, 2026 · 5 revisions

English | Русский

ShowSourceLineNumbers shows the numbers of the source lines in a margin on the left, like an editor does. Numbers start from 1.

Source line numbers and line numbers inside code

A window or a user control:

<ScrollViewer>
    <md:MarkdownViewer Markdown="{Binding Text}"
                        ShowSourceLineNumbers="True"
                        ShowCodeLineNumbers="True"
                        Margin="8,16,24,16" />
</ScrollViewer>

Which lines get a number

A number stands at every source line that has its own place on the screen: lines of text, blank lines, the header of a code block and its lines of code. The closing fence of a code block, the delimiter row of a table and the === or --- under a heading have no place of their own and get no number. The width of the margin is one for the whole document, so it does not jump while you scroll.

With JoinSoftLineBreaks the lines of a paragraph share the lines of the screen: a number stands at the line of the screen where its source line starts, and of several numbers on one line of the screen only the first stays.

ShowCodeLineNumbers is a different numbering: from 1 inside every code block — see Code Blocks.

The look

The margin uses the keys Md.Gutter.FontFamily, Md.Gutter.Foreground, Md.Gutter.FontSize and Md.Gutter.Padding — see Theming. A template of the viewer of your own keeps the margin when it has md:MdLineGutter x:Name="PART_Gutter".

Marks in the margin

Bars and icons of marks stand in the margin: icons to the left of the numbers, bars to the right of them. The margin is wider by their columns only while there are such marks. The same places of lines for a column of your own give coordinates.

Numbers and the source

The numbers are the line numbers of the text in Markdown, the same an editor shows for that text. From code, lines are counted from 0 — see Source Lines and Two Panes.

Beresta.Markdown.Wpf

Basics

Working with Text

Appearance

Integration

Editing

Your Own Syntax

Ready-made Extensions


По-русски

Основы

Работа с текстом

Оформление

Встраивание в приложение

Правка

Свой синтаксис

Готовые расширения

Clone this wiki locally