Four kinds of blocks fold: headings with their sections, alerts, <details> blocks and a language model's reasoning. Headings fold once AreHeadingsFoldable is set; the others fold where the Markdown asks for it.
<mv:MarkdownViewer Source="avares://MyApp/Docs/guide.md" AreHeadingsFoldable="True" />
| Block | Folds when | Starts |
|---|---|---|
| Heading | AreHeadingsFoldable is set |
Expanded |
| Alert | It has a fold marker, > [!NOTE]- or > [!NOTE]+ (needs UseExtendedAlertBlocks() or viewer.UseAlertBlocks()) |
Collapsed with -, expanded with + |
| Details block | Always (<details>, in the default pipeline) |
Collapsed, unless <details open> |
| Thinking block | Always (UseThinkingBlocks()) |
Collapsed, except while a streaming session receives it |
ScrollToAnchor, and so in-document links and the table of contents, expands the blocks around its target before scrolling to it. The find methods expand them to show a match.AreHeadingsFoldable starts each heading with a fold button, as in Obsidian or Notion, for long documents read section by section.
A heading's section is everything after it up to the next heading of the same or a higher level (## folds the blocks below it until the next ## or #), nested sections included. Collapsing a heading hides its section; the heading stays. Expanding it again shows the section as it was, so a nested heading that was collapsed stays collapsed. Every section starts expanded, and a new document (another Markdown, Source or Pipeline) starts with every section expanded. Setting the property renders the document again.
ScrollToAnchor and find expand the sections around their target; a heading navigated to keeps its own section as it was.Each kind has its classes, with an :expanded pseudo-class while its content shows; see Style classes. Their content is hidden by the control, not by a style. For example, to dim collapsed headings and show their button more discreetly:
<Style Selector=":is(TextBlock).markdown-heading-foldable:not(:expanded)">
<Setter Property="Opacity" Value="0.8" />
</Style>
<Style Selector=":is(Control).markdown-heading-fold">
<Setter Property="Opacity" Value="0.6" />
</Style>
<Style Selector=":is(Control).markdown-heading-fold:pointerover">
<Setter Property="Opacity" Value="1" />
</Style>