MarkdView 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MarkdView --version 1.0.0
                    
NuGet\Install-Package MarkdView -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MarkdView" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkdView" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MarkdView" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MarkdView --version 1.0.0
                    
#r "nuget: MarkdView, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MarkdView@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MarkdView&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MarkdView&version=1.0.0
                    
Install as a Cake Tool

MarkdView

License: MIT .NET Version

现代化 WPF Markdown 渲染库,专为 AI 对话场景设计

✨ 特性

  • 🚀 流式渲染 - 完美支持 AI 流式输出,50ms 防抖优化
  • 🎨 语法高亮 - 内置 8+ 语言高亮,VS Code Dark+ 配色
  • 😊 Emoji 彩色渲染 - 基于 Emoji.Wpf 的完整 Emoji 支持
  • 💻 Mac 风格代码块 - 装饰性圆点和一键复制功能
  • 🌓 主题系统 - 浅色/深色/高对比度三套主题,支持自定义
  • 📦 开箱即用 - 无需配置,默认优美样式
  • 高性能 - 缓存机制 + 差分更新
  • 🔧 易扩展 - 基于 Markdig,支持所有 Markdig 扩展

📦 安装

# 使用 NuGet 包管理器
Install-Package MarkdView

# 或使用 .NET CLI
dotnet add package MarkdView

从源码引用(当前阶段):

<ProjectReference Include="..\MarkdView\MarkdView.csproj" />

🚀 快速开始

基础用法

<Window xmlns:markd="clr-namespace:MarkdView.Controls;assembly=MarkdView">
    <markd:MarkdownViewer Markdown="{Binding MarkdownText}" />
</Window>

流式渲染(AI 场景)

// ViewModel
public partial class ChatViewModel : ObservableObject
{
    [ObservableProperty]
    private string _aiResponse = "";

    public async Task StreamResponseAsync()
    {
        await foreach (var chunk in aiClient.StreamAsync())
        {
            AiResponse += chunk; // 自动触发流式渲染
        }
    }
}
<markd:MarkdownViewer
    Markdown="{Binding AiResponse}"
    EnableStreaming="True"
    StreamingThrottle="50" />

高级配置

<markd:MarkdownViewer
    Markdown="{Binding Content}"
    EnableStreaming="True"
    StreamingThrottle="50"
    EnableSyntaxHighlighting="True"
    FontSize="14"
    FontFamily="Microsoft YaHei UI, Segoe UI" />

🎨 主题定制

App.xaml 或资源字典中定义主题颜色:

<ResourceDictionary>
    
    <SolidColorBrush x:Key="Markdown.Foreground" Color="#1E1E1E"/>
    <SolidColorBrush x:Key="Markdown.Background" Color="Transparent"/>

    
    <SolidColorBrush x:Key="Markdown.Heading.Border" Color="#5C9DFF"/>

    
    <SolidColorBrush x:Key="Markdown.Quote.Background" Color="#F9F9F9"/>
    <SolidColorBrush x:Key="Markdown.Quote.Border" Color="#5C9DFF"/>

    
    <SolidColorBrush x:Key="Markdown.Table.Border" Color="#E0E0E0"/>
    <SolidColorBrush x:Key="Markdown.Table.HeaderBackground" Color="#F5F5F5"/>
</ResourceDictionary>

📝 支持的 Markdown 特性

  • ✅ 标题 (H1-H6, 带下划线)
  • ✅ 段落 & 换行
  • 粗体 & 斜体
  • 行内代码
  • ✅ 代码块(Mac 风格 + 语法高亮 + 复制按钮)
  • ✅ 引用块(左侧彩色边框)
  • ✅ 有序/无序列表
  • ✅ 表格(带边框样式)
  • ✅ 链接(可点击)
  • ✅ 图片
  • ✅ 水平分隔线
  • ✅ Emoji 😊(彩色渲染)
  • ✅ 任务列表
  • ✅ GFM 扩展

代码高亮支持

  • C# / JavaScript / TypeScript
  • Python / Java / C/C++
  • Go / Rust / Swift / Kotlin
  • SQL / Bash / PowerShell
  • HTML / CSS / JSON / XML

🏗️ 架构设计

MarkdView/
├── Controls/
│   └── MarkdownViewer.xaml(.cs)    # 主控件
├── Renderers/
│   └── Blocks/
│       └── CodeBlockRenderer.cs     # 代码块渲染器
├── Extensions/
│   ├── Controls/
│   │   └── CodeBlockControl.xaml    # 代码块控件(复制功能)
│   ├── Behaviors/                   # 自定义行为
│   └── Converters/                  # 值转换器
├── Themes/
│   ├── Light.xaml                   # 浅色主题
│   ├── Dark.xaml                    # 深色主题
│   └── HighContrast.xaml            # 高对比度主题
└── Samples/
    ├── Markdown/                    # Markdown 示例
    └── Themes/                      # 主题切换示例

🔄 对比其他库

特性 MarkdView Markdig.Wpf MdXaml
流式渲染
语法高亮 ⚠️
现代样式
维护状态 🆕 ⏸️ ⏸️
性能优化 ⚠️ ⚠️

📊 性能

  • 首次渲染: 1KB Markdown ~5ms
  • 流式更新: 50ms 防抖,CPU < 5%
  • 大文档: 100KB Markdown ~200ms
  • 内存占用: ~2MB (小型文档)

🛠️ 开发路线图

v1.0.0 (已发布)

  • 基础渲染与流式支持
  • 完整语法高亮(8+ 语言)
  • Mac 风格代码块(三色圆点 + 复制按钮)
  • Emoji 彩色渲染(基于 Emoji.Wpf)
  • 完整主题系统(浅色/深色/高对比度)

v1.1.0 (计划)

  • 链接导航事件
  • 代码块行号显示
  • 更多语法高亮语言

v1.2.0 (计划)

  • LaTeX 数学公式支持
  • 虚拟化渲染(大文档优化)
  • 导出为 HTML/PDF

🤝 贡献

欢迎提交 Issue 和 PR!

📄 许可证

MIT License - 详见 LICENSE 文件

🙏 致谢


Made with ❤️ for WPF & AI developers

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.11 170 3/1/2026
1.0.10 114 2/27/2026
1.0.9 116 2/27/2026
1.0.8 221 11/25/2025
1.0.7 424 11/19/2025
1.0.6 424 11/19/2025
1.0.5 418 11/19/2025
1.0.4 424 11/19/2025
1.0.3 425 11/19/2025
1.0.1 353 11/17/2025
1.0.0 262 11/16/2025

v1.0.0: Initial release with streaming support, syntax highlighting, emoji rendering, and Mac-style code blocks with copy functionality.