Repository navigation
Task Lists
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 docsAreControlsEditable="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;
};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.
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 · Issues · MIT License
Basics
- Getting Started
- How It Renders
- Supported Markdown
- Settings and Hooks
- Scrolling and Virtualization
- Comparison
Working with Text
Appearance
Integration
- Application Links
- Images
- Untrusted Text
- Task Lists
- Source Lines and Two Panes
- Coordinates
- Live Preview
Editing
Your Own Syntax
Ready-made Extensions
Основы
- Начало работы
- Как рисует вьюер
- Что поддерживается
- Настройки и перехват
- Прокрутка и виртуализация
- Сравнение
Работа с текстом
Оформление
Встраивание в приложение
- Ссылки приложения
- Картинки
- Чужой текст
- Списки задач
- Строки исходника и две панели
- Координаты
- Живой предпросмотр
Правка
Свой синтаксис
Готовые расширения