Repository navigation
Getting Started
English | Русский
The viewer is a library: you add it to a WPF application, connect its theme once and put
MarkdownViewer where the document should be.
Requirements: .NET 7 or later (net7.0-windows) with WPF.
As a NuGet package.
Terminal, in the folder of your application project:
dotnet add package Beresta.Markdown.WpfIntelliSense documentation comes in English and Russian: Visual Studio with a Russian interface shows the Russian one.
To edit Markdown right where it is drawn, add the second package, Beresta.Markdown.Wpf.Editor — see
Editor.
The viewer draws blocks with the templates of its theme, Themes/Generic.xaml. Merge it into the
application resources once: the theme keys work only from there. Without it the viewer shows a hint
with this address instead of the document and writes the same to Trace.
App.xaml, the application resources:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Beresta.Markdown.Wpf;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>Your own dictionary that overrides theme keys goes after this one — see Theming.
The viewer has no scroll bars of its own: put it into a ScrollViewer. Other places for it are in
Scrolling and Virtualization. One XAML namespace,
xmlns:md="https://github.com/porohkun/Beresta.Markdown.Wpf", gives every type of the library: the
viewer, ready-made extensions, presenters — the examples of this wiki use it.
MainWindow.xaml, the whole window:
<Window x:Class="YourApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:md="https://github.com/porohkun/Beresta.Markdown.Wpf"
Title="Markdown" Width="800" Height="600">
<ScrollViewer>
<md:MarkdownViewer x:Name="Viewer" Margin="24,16" />
</ScrollViewer>
</Window>MainWindow.xaml.cs, in the constructor after InitializeComponent():
Viewer.Markdown = """
# Hello
This is **Markdown** in a *WPF* window.
- [x] theme connected
- [ ] read the wiki
""";Markdown can be bound: Markdown="{Binding Text}". A new value is applied to the shown document as
edits, so a text that changes often is fine — see Live Preview.
The viewer does not set the font and the color of the text: they come from your window. The theme sets only sizes, margins and accents.
- Open the links of your application, or decide what happens with every link — Application Links.
- Change colors and fonts, add a dark theme — Theming.
- Connect the syntax of GitHub, Obsidian or another program — Sets.
- Show a chat or a feed — Scrolling and Virtualization.
- See everything that can be set or hooked — Settings and Hooks.
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
Основы
- Начало работы
- Как рисует вьюер
- Что поддерживается
- Настройки и перехват
- Прокрутка и виртуализация
- Сравнение
Работа с текстом
Оформление
Встраивание в приложение
- Ссылки приложения
- Картинки
- Чужой текст
- Списки задач
- Строки исходника и две панели
- Координаты
- Живой предпросмотр
Правка
Свой синтаксис
Готовые расширения