### Complete Markdown Editor Example (C#) Source: https://context7.com/orgelecho/elecho.mdviewer/llms.txt The code-behind for the complete Markdown editor example. It initializes the window and sets the initial Markdown text for the editor, demonstrating how to populate the editor with content. ```csharp // MainWindow.xaml.cs using System.Windows; namespace MdTest { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); // 设置初始 Markdown 内容 MdEditor.Text = @"# 欢迎使用 EleCho.MdViewer 这是一个 **WPF Markdown 渲染器**示例。 "; } } } ``` -------------------------------- ### Configure App.xaml with ControlsDictionary and ThemeDictionary Source: https://context7.com/orgelecho/elecho.mdviewer/llms.txt This example shows the complete configuration within App.xaml, merging the ControlsDictionary for base styles and ThemeDictionary for color mode (Light or Dark). ```xml ``` -------------------------------- ### Complete Markdown Editor Example (XAML) Source: https://context7.com/orgelecho/elecho.mdviewer/llms.txt A full WPF application example demonstrating a Markdown editor with a live preview. The UI is split into two columns: a TextBox for Markdown input on the left and a MarkdownViewer for rendering on the right. ```xml ``` -------------------------------- ### Handle Markdown Link Navigation Events (C#) Source: https://context7.com/orgelecho/elecho.mdviewer/llms.txt Subscribe to the static LinkNavigate event of MarkdownWpfRenderer to implement custom logic when a user clicks on a hyperlink within the Markdown content. This example shows how to open the URL in the default browser. ```csharp using EleCho.MdViewer.Markdown; using System.Diagnostics; using System.Windows; namespace MyApp { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); // 订阅链接导航事件 MarkdownWpfRenderer.LinkNavigate += OnLinkNavigate; } private void OnLinkNavigate(object? sender, MarkdownLinkNavigateEventArgs e) { // 获取链接 URL string? url = e.Link; if (!string.IsNullOrEmpty(url)) { // 使用默认浏览器打开链接 Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true }); } } } } ``` -------------------------------- ### Configure Theme Dictionary for MdViewer Source: https://github.com/orgelecho/elecho.mdviewer/blob/master/README.md Include the ControlsDictionary and ThemeDictionary in your ResourceDictionary. Set ColorMode to 'Dark' for dark mode. ```xml ``` -------------------------------- ### Switch ThemeDictionary ColorMode Source: https://context7.com/orgelecho/elecho.mdviewer/llms.txt Demonstrates how to switch between light and dark themes by setting the ColorMode property of the ThemeDictionary. Ensure ControlsDictionary is also merged. ```xml ``` -------------------------------- ### Add XMLNS Namespaces for EleCho.MdViewer Source: https://github.com/orgelecho/elecho.mdviewer/blob/master/README.md Add these XML namespaces to your project to use EleCho.MdViewer components. Ensure the assembly is referenced. ```xml xmlns:mu="clr-namespace:EleCho.MdViewer.Markup;assembly=EleCho.MdViewer" xmlns:md="clr-namespace:EleCho.MdViewer;assembly=EleCho.MdViewer" ``` -------------------------------- ### Custom Markdown Theme Colors (XAML) Source: https://context7.com/orgelecho/elecho.mdviewer/llms.txt Define custom styles for Markdown elements by creating a ResourceDictionary and specifying resources for MarkdownResKey. This allows full control over foreground, background, and border colors for various Markdown components. ```xml #dddddd #8E44AD #dddddd #0CFFFFFF #dddddd #8C8E44AD #dddddd Transparent #8C8E44AD #dddddd #0CFFFFFF #0CFFFFFF #3d3d3d #c5c5c5 #8C8E44AD #9F8E44AD #8E44AD #0CFFFFFF #3d3d3d ``` -------------------------------- ### Integrate MarkdownViewer in WPF XAML Source: https://context7.com/orgelecho/elecho.mdviewer/llms.txt Add the MarkdownViewer control to your WPF application by referencing the necessary namespaces and configuring resource dictionaries for styling and theming. ```xml ``` -------------------------------- ### Use MdViewer Control in WPF Source: https://github.com/orgelecho/elecho.mdviewer/blob/master/README.md Embed the MarkdownViewer control within a ScrollViewer for scrollable content. Bind its Content property to your Markdown source. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.