Repository navigation
Theming
English | Русский
Every color, size, margin and interface string of the viewer is a resource key Md.<Block>.<Property>.
The templates take them with DynamicResource, so a key overridden in the resources of the
application, a window or a viewer applies at once — even while the application runs.

A key is overridden in the resources of the application, a window or one viewer.
App.xaml, the application resources (xmlns:sys="clr-namespace:System;assembly=System.Runtime"
on the root element):
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Beresta.Markdown.Wpf;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="Md.Paragraph.LinkForeground" Color="#0969DA" />
<SolidColorBrush x:Key="Md.CodeBlock.Background" Color="#F6F8FA" />
<sys:Double x:Key="Md.Paragraph.FontSize">15</sys:Double>
</ResourceDictionary>
</Application.Resources>One viewer with smaller text:
<md:MarkdownViewer Markdown="{Binding Text}">
<md:MarkdownViewer.Resources>
<sys:Double x:Key="Md.Paragraph.FontSize">12</sys:Double>
</md:MarkdownViewer.Resources>
</md:MarkdownViewer>A key keeps the type of its default value: sizes are sys:Double, margins and paddings Thickness,
colors Brush, Md.List.MarkerWidth and Md.Footnote.MarkerWidth are GridLength. The defaults are
in Themes/Generic.xaml.
The theme does not set the font and the color of the text: the viewer takes them from your
application, like a TextBlock does. Set Md.Paragraph.FontFamily, Md.Paragraph.Foreground and
their heading counterparts only when the text of the viewer must differ from the rest of the
application.
A dark theme is one more dictionary with the same keys, merged after the theme of the viewer and removed to go back. The text color and the background come from your window, so switch them there.
Themes/MarkdownDark.xaml, a resource dictionary in your application:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="Md.Paragraph.LinkForeground" Color="#58A6FF" />
<SolidColorBrush x:Key="Md.Heading.LinkForeground" Color="#58A6FF" />
<SolidColorBrush x:Key="Md.InlineCode.Background" Color="#343942" />
<SolidColorBrush x:Key="Md.InlineCode.Foreground" Color="#E6EDF3" />
<SolidColorBrush x:Key="Md.InlineCode.BorderBrush" Color="#3D444D" />
<SolidColorBrush x:Key="Md.CodeBlock.Background" Color="#161B22" />
<SolidColorBrush x:Key="Md.CodeBlock.Foreground" Color="#E6EDF3" />
<SolidColorBrush x:Key="Md.CodeBlock.BorderBrush" Color="#3D444D" />
<SolidColorBrush x:Key="Md.Code.Keyword.Foreground" Color="#FF7B72" />
<SolidColorBrush x:Key="Md.Code.Type.Foreground" Color="#FFA657" />
<SolidColorBrush x:Key="Md.Code.String.Foreground" Color="#A5D6FF" />
<SolidColorBrush x:Key="Md.Code.Number.Foreground" Color="#79C0FF" />
<SolidColorBrush x:Key="Md.Code.Comment.Foreground" Color="#8B949E" />
<SolidColorBrush x:Key="Md.Code.Preprocessor.Foreground" Color="#D2A8FF" />
<SolidColorBrush x:Key="Md.Code.Tag.Foreground" Color="#7EE787" />
<SolidColorBrush x:Key="Md.Code.Attribute.Foreground" Color="#79C0FF" />
<SolidColorBrush x:Key="Md.Code.Inserted.Foreground" Color="#AFF5B4" />
<SolidColorBrush x:Key="Md.Code.Deleted.Foreground" Color="#FFDCD7" />
<SolidColorBrush x:Key="Md.Kbd.Background" Color="#161B22" />
<SolidColorBrush x:Key="Md.Kbd.Foreground" Color="#E6EDF3" />
<SolidColorBrush x:Key="Md.Kbd.BorderBrush" Color="#3D444D" />
<SolidColorBrush x:Key="Md.Quote.BorderBrush" Color="#3D444D" />
<SolidColorBrush x:Key="Md.Table.BorderBrush" Color="#3D444D" />
<SolidColorBrush x:Key="Md.Table.HeaderBackground" Color="#161B22" />
<SolidColorBrush x:Key="Md.Callout.Note.Brush" Color="#4493F8" />
<SolidColorBrush x:Key="Md.Callout.Tip.Brush" Color="#3FB950" />
<SolidColorBrush x:Key="Md.Callout.Important.Brush" Color="#AB7DF8" />
<SolidColorBrush x:Key="Md.Callout.Warning.Brush" Color="#D29922" />
<SolidColorBrush x:Key="Md.Callout.Caution.Brush" Color="#F85149" />
</ResourceDictionary>The captions of the context menu, the name of the code copy button, the titles of callout kinds and
of a collapsible block without its own title, the captions of the properties card are keys too, English
by default; the editor adds the captions of the menu of its source, Md.Source.ContextMenu.*. Translate them in the
application resources.
App.xaml, the application resources:
<sys:String x:Key="Md.ContextMenu.Copy">Копировать</sys:String>
<sys:String x:Key="Md.ContextMenu.CopyMarkdown">Копировать как Markdown</sys:String>
<sys:String x:Key="Md.ContextMenu.SelectAll">Выделить всё</sys:String>
<sys:String x:Key="Md.CodeBlock.CopyToolTip">Копировать код</sys:String>
<sys:String x:Key="Md.Callout.Note.Title">Заметка</sys:String>
<sys:String x:Key="Md.Callout.Tip.Title">Совет</sys:String>
<sys:String x:Key="Md.Callout.Important.Title">Важно</sys:String>
<sys:String x:Key="Md.Callout.Warning.Title">Предупреждение</sys:String>
<sys:String x:Key="Md.Callout.Caution.Title">Осторожно</sys:String>
<sys:String x:Key="Md.Details.Title">Подробности</sys:String>
<sys:String x:Key="Md.Properties.Remove">Убрать</sys:String>
<sys:String x:Key="Md.Properties.Add">Добавить свойство</sys:String>
<sys:String x:Key="Md.Properties.AddItem">Добавить пункт</sys:String>A callout kind looks the way three keys say: Md.Callout.<Kind>.Brush
is the color of the bar, the icon and the title, Md.Callout.<Kind>.Icon is a Geometry,
Md.Callout.<Kind>.Title is the title. <Kind> is the kind from the Markdown with a capital first
letter: [!question] takes Md.Callout.Question.*. A kind with its own Brush gets its own color and
icon, any other kind is drawn as a note; a kind without its own Title is titled with its name.
App.xaml, the application resources:
<SolidColorBrush x:Key="Md.Callout.Question.Brush" Color="#BF8700" />
<Geometry x:Key="Md.Callout.Question.Icon">F0 M0.5,8 A7.5,7.5 0 1 1 15.5,8 A7.5,7.5 0 1 1 0.5,8 Z M2,8 A6,6 0 1 0 14,8 A6,6 0 1 0 2,8 Z M7,7 L9,7 L9,9 L7,9 Z</Geometry>
<sys:String x:Key="Md.Callout.Question.Title">Question</sys:String>Now > [!QUESTION] is drawn in its own color, with its own icon and title.
| Part | Keys |
|---|---|
| Paragraph |
Md.Paragraph.FontFamily*, Md.Paragraph.Foreground*, Md.Paragraph.FontSize, Md.Paragraph.LinkForeground
|
| Headings |
Md.Heading.FontFamily*, Md.Heading.Foreground*, Md.Heading.LinkForeground; Md.Heading1.FontSize, Md.Heading1.FontWeight, Md.Heading1.Margin and the same for levels 2–6 |
| Inline code |
Md.InlineCode.FontFamily, .FontSize, .Foreground, .Background, .BorderBrush, .BorderThickness, .Padding, .CornerRadius
|
Keys, <kbd>
|
Md.Kbd.FontFamily, .Foreground, .Background, .BorderBrush, .BorderThickness, .Padding, .CornerRadius
|
| Code block |
Md.CodeBlock.FontFamily, .FontSize, .Foreground, .Background, .BorderBrush, .BorderThickness, .Padding, .CornerRadius, .LineNumberForeground, .LineNumberMargin
|
| Code block header |
Md.CodeBlock.HeaderFontFamily*, .HeaderForeground, .HeaderFontSize, .HeaderMargin
|
| Code copy button |
Md.CodeBlock.CopyToolTip, Md.CodeBlock.CopyIcon, Md.CodeBlock.CopiedIcon (both Geometry), .CopyIconSize, .CopyButtonPadding, .CopyButtonMargin; the frame — .BorderThickness and .CornerRadius of the block |
| Code highlighting |
Md.Code.<Look>.Foreground and the styles Md.Code.<Look>.Style for the looks Keyword, Type, String, Number, Comment, Preprocessor, Tag, Attribute, Inserted, Deleted; Md.Code.Punctuation.Style — see Code Blocks
|
| Quote |
Md.Quote.BorderBrush, .BorderThickness, .Padding, .Margin
|
| Callout |
Md.Callout.BorderThickness, .Padding, .Margin, .CornerRadius, .Background, .ChevronMargin, .ContentMargin; the fold arrow — Md.Details.MarkerIcon and Md.Details.MarkerSize; for the kinds Note, Tip, Important, Warning, Caution and, for the ready-made extensions, Abstract, Info, Todo, Success, Question, Failure, Danger, Bug, Example, Quote — Md.Callout.<Kind>.Brush, .Icon (Geometry), .Title
|
| Collapsible block |
Md.Details.Title, .Margin, .ContentMargin, .MarkerForeground, .MarkerIcon (Geometry), .MarkerSize, .MarkerMargin
|
| Titles, captions, icons |
Md.Title.FontWeight — titles of callouts and collapsible blocks, terms of definition lists, keys of properties; Md.Caption.FontStyle — captions of figures and alt texts of images; Md.Icon.Size, Md.Icon.Margin — icons of callouts and link cards |
| List |
Md.List.Margin, Md.List.MarkerWidth, Md.List.ItemSpacing
|
| Definition list |
Md.DefinitionList.Margin, .DefinitionMargin
|
| Table |
Md.Table.BorderBrush, .BorderThickness, .CellPadding, .HeaderBackground
|
| Marked text, abbreviation |
Md.Marked.Background, Md.Abbreviation.UnderlineBrush
|
| Figure |
Md.Figure.Margin, .CaptionForeground, .CaptionFontSize
|
| Footer |
Md.Footer.Margin, .Foreground, .FontSize
|
| Image | Md.Image.AltForeground |
| Task |
Md.Task.Size, .Margin, .Brush, .MarkBrush
|
| Footnote |
Md.Footnote.MarkerWidth, Md.Footnote.MarkerForeground, Md.Footnote.LinkFontSize
|
| Rule, blank line |
Md.HorizontalRule.Margin, Md.BlankLine.Height
|
| Line numbers |
Md.Gutter.FontFamily*, Md.Gutter.Foreground, .FontSize, .Padding
|
| Selection | Md.Selection.Brush |
| Marks |
Md.Mark.<Name>.Brush, Md.Mark.<Name>.LineBrush for the names Found, Current, Added, Removed, Changed, Comment — see Marks and Search; Md.Mark.UnderlineThickness, .FrameThickness, .CaretThickness, .BarWidth, .IconSize
|
| Empty places |
Md.Gap.Brush — see two panes
|
| Context menu |
Md.ContextMenu (the menu itself), Md.ContextMenu.Copy, .CopyMarkdown, .SelectAll
|
* Not set by default: the value comes from the application.
Whole styles of blocks and inline formatting are keys too — see Styles and Templates.
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
Основы
- Начало работы
- Как рисует вьюер
- Что поддерживается
- Настройки и перехват
- Прокрутка и виртуализация
- Сравнение
Работа с текстом
Оформление
Встраивание в приложение
- Ссылки приложения
- Картинки
- Чужой текст
- Списки задач
- Строки исходника и две панели
- Координаты
- Живой предпросмотр
Правка
Свой синтаксис
Готовые расширения