Rhizine.AvalonEdit.MarkdownEditor
1.0.0
dotnet add package Rhizine.AvalonEdit.MarkdownEditor --version 1.0.0
NuGet\Install-Package Rhizine.AvalonEdit.MarkdownEditor -Version 1.0.0
<PackageReference Include="Rhizine.AvalonEdit.MarkdownEditor" Version="1.0.0" />
paket add Rhizine.AvalonEdit.MarkdownEditor --version 1.0.0
#r "nuget: Rhizine.AvalonEdit.MarkdownEditor, 1.0.0"
// Install Rhizine.AvalonEdit.MarkdownEditor as a Cake Addin #addin nuget:?package=Rhizine.AvalonEdit.MarkdownEditor&version=1.0.0 // Install Rhizine.AvalonEdit.MarkdownEditor as a Cake Tool #tool nuget:?package=Rhizine.AvalonEdit.MarkdownEditor&version=1.0.0
MarkdownEditor Control Usage Guide
The MarkdownEditor is a custom control built on top of AvalonEdit, designed to provide an enhanced editing experience for Markdown documents.
"Why should I use this over something like MarkDig?"
You probably shouldn't. I made this control to be a lightweight editor/viewer for Markdown documents with customizable syntax highlighting that doesn't convert the text to HTML, but it's not a full-fledged Markdown parser. If you're already using AvalonEdit in your project or you want a way to add syntax highlighting without a ton of overhead, this control might be a good fit for your project.
Basic Usage
- Add a reference to the
Rhizine.AvalonEdit.MarkdownEditor
library in your project. Add the following namespace to your XAML file:
xmlns:md="clr-namespace:Rhizine.AvalonEdit.MarkdownEditor;assembly=Rhizine.AvalonEdit.MarkdownEditor"
- Add the following namespace to your XAML file:
<md:MarkdownEditor x:Name="myMarkdownEditor" />
You can also create and manipulate the MarkdownEditor in your C# code:
MarkdownEditor editor = new MarkdownEditor(); editor.Text = "# Welcome to MarkdownEditor";
Binding to a Document
The MarkdownEditor has a Document
property that you can bind to a string property in your view model:
<md:MarkdownEditor
Document="{Binding CurrentPageContent, Mode=TwoWay}"
IsReadOnly="{Binding IsReadOnly}"
IsMarkdownHidden="{Binding IsReadOnly}"
FontFamily="Segoe UI"
FontSize="14"
ShowLineNumbers="False"/>
Features
Syntax Highlighting
The MarkdownEditor comes with several highlighting options:
- Default: A custom highlighting scheme defined in the control.
- AvalonEdit Markdown: The built-in Markdown highlighting from AvalonEdit.
- AvalonEdit MarkdownWithFontSize: Another built-in option from AvalonEdit.
- Custom: Allows you to define your own highlighting scheme.
To change the highlighting type:
myMarkdownEditor.HighlightingType = MarkdownHighlightingType.AvalonEditMarkdown;
Custom Highlighting
You can provide your own custom highlighting:
myMarkdownEditor.HighlightingType = MarkdownHighlightingType.Custom;
myMarkdownEditor.CustomHighlighting = YourCustomHighlightingDefinition;
Markdown Hiding
The MarkdownEditor can hide Markdown syntax for a cleaner reading experience:
myMarkdownEditor.IsMarkdownHidden = true;
Read-Only Mode
You can set the editor to read-only mode, which applies a different style:
myMarkdownEditor.IsReadOnly = true;
Advanced Usage
Registering Custom Highlighting
You can register a custom highlighting from an .xshd file:
MarkdownEditor.RegisterCustomHighlighting("MyCustomHighlighting",
new string[] { ".md", ".markdown" },
"MyNamespace.MyCustomHighlighting.xshd");
Then use it like this:
myMarkdownEditor.HighlightingType = MarkdownHighlightingType.Custom;
myMarkdownEditor.CustomHighlighting = HighlightingManager.Instance.GetDefinition("MyCustomHighlighting");
Accessing the Underlying TextEditor
The MarkdownEditor inherits from AvalonEdit's TextEditor, so you have access to all its properties and methods:
myMarkdownEditor.Options.EnableHyperlinks = true;
myMarkdownEditor.Options.EnableEmailHyperlinks = true;
Styling
The MarkdownEditor uses a default style defined in Themes/Generic.xaml. You can override this style in your application to customize the appearance of the control.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-windows7.0 is compatible. |
-
net8.0-windows7.0
- AvalonEdit (>= 6.3.0.90)
- Microsoft.Xaml.Behaviors.Wpf (>= 1.1.135)
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.0 | 106 | 10/6/2024 |