Make Wpf Markdown Presenter
БесплатноБез исполняемых скриптовНе проверенGenerates a WPF MarkdownPresenter: a ContentControl with a bindable Markdown dependency property that parses Markdig into a FlowDocument and hosts it in a…
от christian289★ 42 звезды на GitHubОб этом скилле
WPF Markdown Presenter Generator
If $0 is empty, use the AskUserQuestion tool to ask: "Enter the presenter control name (e.g., MarkdownPresenter, ChatMarkdownView)". Do NOT proceed until a valid name is provided. Use the response as the control name for all subsequent steps.
Generate a $0 control: a ContentControl with a bindable Markdown dependency property that parses markdown with Markdig, builds a WPF FlowDocument, and hosts it in a selectable, content-hugging read-only RichTextBox.
- Replace
{Namespace}with the project's root namespace detected from csproj or existing code. - Replace
{Project}with the target project path (a WPF Application or WPF control library — must haveUseWPF).
The full rationale for every choice below is in two knowledge topics — fetch with
WpfDevPackMcp get_wpf_topic:rendering-markdown-in-wpf(the AST→FlowDocument dispatcher, the "neverToString()a node" rule, theBlock/Inlinealiasing, Hyperlink scheme validation) anddisplaying-selectable-rich-text-in-wpf(the read-only RichTextBox host, the content-huggingHuggingRichTextBox,MouseWheelforwarding, streaming throttle).
Usage
/wpf-dev-pack:make-wpf-markdown-presenter MarkdownPresenter
Required Packages
<PackageReference Include="Markdig" Version="1.*" />
- Markdig is required (markdown parsing). Verify the current version and the
exact API surface with HandMirror before emitting (
inspect_nuget_package/inspect_nuget_package_typeonMarkdig), since the AST node type names drive theswitch. - The code uses the WPF-UI (
Wpf.Ui) theme-brush keysTextFillColorPrimaryBrush/TextFillColorSecondaryBrushviaSetResourceReference, and aWpf.Ui.Controls.Buttonfor the code-block Copy button. If WPF-UI is not installed, swap those for stock WPF (SystemColors.ControlTextBrushKeyresource reference, and a plainSystem.Windows.Controls.Button). Seeintegrating-wpfui-fluentfor the brush keys.
Generated Code
$0.cs
The three using-aliases at the top are mandatory — Markdig.Syntax.Block
and System.Windows.Documents.Block (and the two Inline types) collide
(CS0104), so both must be aliased in any file that both parses markdown and
builds a FlowDocument.
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Markdig;
using Markdig.Syntax;
using Markdig.Syntax.Inlines;
using MarkdigBlock = Markdig.Syntax.Block; // markdown AST node
using MarkdigInline = Markdig.Syntax.Inlines.Inline; // markdown AST inline
using FlowBlock = System.Windows.Documents.Block; // FlowDocument node
namespace {Namespace}.Controls;
/// <summary>
/// A ContentControl that renders a bound Markdown string as a selectable WPF
/// FlowDocument hosted in a read-only RichTextBox. Unhandled Markdig AST nodes
/// are recursed (Container), degraded to inlines/lines (Leaf), or skipped —
/// never ToString()'d (the default ToString returns the type name).
/// </summary>
public sealed class $0 : ContentControl
{
private static readonly MarkdownPipeline _pipeline =
new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
public static readonly DependencyProperty MarkdownProperty =
DependencyProperty.Register(nameof(Markdown), typeof(string), typeof($0),
new PropertyMetadata(null, OnMarkdownChanged));
public string? Markdown
{
get => (string?)GetValue(MarkdownProperty);
set => SetValue(MarkdownProperty, value);
}
// Coalesce re-renders during fast streaming instead of rebuilding per token.
private readonly DispatcherTimer _renderTimer =
new() { Interval = TimeSpan.FromMilliseconds(50) }; // ~20 Hz
public $0()
{
_renderTimer.Tick += (_, _) => { _renderTimer.Stop(); Render(Markdown); };
}
private static void OnMarkdownChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var self = ($0)d;
self._renderTimer.Stop();
self._renderTimer.Start(); // debounce: render once the burst settles
}
// Render: parse markdown -> build a FlowDocument -> host it in a read-only RichTextBox.
private void Render(string? markdown)
{
if (string.IsNullOrEmpty(markdown)) { Content = null; return; }
var doc = new FlowDocument { PagePadding = new Thickness(0), FontSize = 14 };
foreach (MarkdigBlock block in Markdig.Markdown.Parse(markdown, _pipeline))
{
FlowBlock? b = RenderBlock(block);
if (b is not null) { doc.Blocks.Add(b); }
}
var host = new HuggingRichTextBox
{
Document = doc,
IsReadOnly = true, // selection + Ctrl+C; no editing, no caret
IsDoc
Установить Make Wpf Markdown Presenter в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Make Wpf Markdown Presenter?
Generates a WPF MarkdownPresenter: a ContentControl with a bindable Markdown dependency property that parses Markdig into a FlowDocument and hosts it in a selectable, content-hugging read-only RichTextBox. Use when rendering LLM/chat markdown output as selectable rich text in WPF, or when building a chat/markdown view. Usage: /wpf-dev-pack:make-wpf-markdown-presenter <Name>
Как установить скилл Make Wpf Markdown Presenter?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Make Wpf Markdown Presenter запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic