Skip to content

Task Lists

Pavel edited this page Oct 21, 2026 · 6 revisions

English | Русский

A list item that starts with [ ] or [x] gets a picture of a check box instead of that text: an empty square or a filled one with a check mark. By default it is a picture, not a control: a click does nothing. A box that ticks the task in the source — see Ticking tasks.

Any .md file:

- [x] take screenshots
- [ ] write the docs

Ticking tasks

AreControlsEditable="True" turns task boxes into controls: a click writes x or a space between the brackets of the task, and [X] counts as ticked too. The new text goes to Markdown; a two-way binding hands it to your application. The same switch makes collapsible blocks write whether they are expanded — see Callouts → Folding in the source. It is inherited, so a window can set it for all its viewers.

MainWindow.xaml:

<md:MarkdownViewer Markdown="{Binding Text, Mode=TwoWay}" AreControlsEditable="True" />

Before the text changes, the viewer raises the bubbling routed event SourceEditRequested. Its Edit is the change — Start and Length of the replaced piece of the shown text and the new Text; Edit.ApplyTo(text) makes the new text — and Node is the model of the control. A handler that sets Handled applies the edit itself, and Markdown stays as it is. So a preview next to an editor puts the click into the editor, where Ctrl+Z undoes it.

MainWindow.xaml.cs, in the constructor after InitializeComponent(); Editor is the TextBox the viewer shows — see Live Preview:

Viewer.SourceEditRequested += (_, e) =>
{
    Editor.Select(e.Edit.Start, e.Edit.Length);
    Editor.SelectedText = e.Edit.Text;
    e.Handled = true;
};

Copying and the look

A task is copied as [x] or [ ] in plain text and as - [x] in Markdown. The picture is drawn by md:MdTaskMark with the style Md.Task.Style; its keys are the size Md.Task.Size, the color Md.Task.Brush — the frame of an empty box, the fill of a done one and the sign of a status — the check mark Md.Task.MarkBrush and the margin Md.Task.Margin. The TaskTemplate of a style provider replaces the picture — see Styles and Templates; a control in it ticks the task with MarkdownViewer.ActivateWidgetCommand — see Extensions.

App.xaml, the application resources after the theme of the viewer:

<SolidColorBrush x:Key="Md.Task.Brush" Color="#1A7F37" />

For screen readers a task is a check box with the state of the task, available while controls edit the source — see Accessibility.

Task statuses

Obsidian statuses [/], [-], [>], [?] and [!] come with the ready-made extension TaskStatuses: a sign in the same box, and Task.Status of the task model is the status character. A click on a box with a status, while controls edit the source, writes the next status: /, -, >, ?, ! and / again.

Beresta.Markdown.Wpf

Basics

Working with Text

Appearance

Integration

Editing

Your Own Syntax

Ready-made Extensions


По-русски

Основы

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

Оформление

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

Правка

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

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

Clone this wiki locally