Wpf Markdown



Tx, problem,the creation of the flow document is separate from the data rules.Essentially one area builds the text,and the engine is taking the content 'knowing' its rtf formatted and placing it into a document so the rtf box can read it.So this doesn't really work for me, or i would have done this. Although, i suppose it may be an option that i create a flowdocument xml that i send to the.

Description

For projects that support PackageReference, copy this XML node into the project file to reference the package.
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
  1. See full list on github.com.
  2. With this, WPF can directly support markdown as it is and we can use Markdown Sharp to convert to HTML. I referenced the following post, but there are old enough now. Markdown for C#/WPF Project (MarkdownSharp) Lightly styled text library for WPF?
  3. Markdown Monster is comprised of one main WPF EXE project which contains the bulk of code, plus several Addin projects that handle things like Weblog Publishing, Screen Captures and the Snippet Editor. To start I unloaded the Addin projects to focus only on the main project first.
  4. Markdown Monster Markdown Monster is an easy to use and extensible Markdown Editor, Viewer and Weblog Publisher for Windows. Our goal is to provide the best Markdown specific editor for Windows and make it as easy as possible to create Markdown documents.

Markdown editor is a simple markdown wpf control based on markdig library.

  1. Enable or disable markdown editor:
  1. Auto-update your markdown document after specific intervall
Wpf
  1. You can disable the auto-update feature and update your document manually

What's New Change Log

Markdown editor is a simple markdown wpf control based on markdig library.

  1. Enable or disable markdown editor:
  1. Auto-update your markdown document after specific intervall
  1. You can disable the auto-update feature and update your document manually
Show more

Dependencies

    • Markdig.Wpf(>= 0.2.7)

Used By

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

VersionDownloadsLast updated
1.0.0.38003 473 3/19/2019
Wpf Markdown

Wpf Markdown To Flowdocument

-->

The MarkdownTextBlock control provides full markdown parsing and rendering for Universal Windows Apps. Originally created for the open source reddit app Baconit, the control was engineered to be simple to use and very efficient. One of the main design considerations for the control was it needed to be performant enough to provide a great user experience in virtualized lists. With the custom markdown parser and efficient XAML rendering, we were able to achieve excellent performance; providing a smooth UI experience even with complex Markdown on low end hardware.

Under the hood, the control uses XAML sub-elements to build the visual rendering tree for the Markdown input. We chose to use full XAML elements overusing the RichEditTextBlock control because the RichEditTextBlock isn't flexible enough to correctly render all of the standard Markdown styles.

Syntax

Limitations

Here are some limitations you may encounter:

  • All images are stretched with the same stretch value (defined by ImageStretch property)
  • Relative Links & Relative Images needs to be handled manually using LinkClicked event.

Wpf Richtextbox Markdown

Sample Output

Note: scrolling is smooth, the gif below is not.

Properties

The MarkdownTextBlock control is highly customizable to blend with any theme. Customizable properties include:

PropertyTypeDescription
CodeBackgroundBrushGets or sets the brush used to fill the background of a code block
CodeBorderBrushBrushGets or sets the brush used to render the border fill of a code block
CodeBorderThicknessThicknessGets or sets the thickness of the border around code blocks
CodeFontFamilyFontFamilyGets or sets the font used to display code. If this is null, then Windows.UI.Xaml.Media.FontFamily is used
CodeForegroundBrushGets or sets the brush used to render the text inside a code block. If this is null, then Foreground is used
CodeMarginThicknessGets or sets the space between the code border and the text
CodePaddingThicknessGets or sets space between the code border and the text
CodeStylingStyleDictionaryGets or sets the Default Code Styling for Code Blocks
EmojiFontFamilyFontFamilyGets or sets the font used to display emojis. If this is null, then Segoe UI Emoji font is used
Header1FontSizedoubleGets or sets the font size for level 1 headers
Header1FontWeightFontWeightGets or sets the font weight to use for level 1 headers
Header1ForegroundBrushGets or sets the foreground brush for level 1 headers
Header1MarginThicknessGets or sets the margin for level 1 headers
Header2FontSizedoubleGets or sets the font size for level 2 headers
Header2FontWeightFontWeightGets or sets the font weight to use for level 2 headers
Header2ForegroundBrushGets or sets the foreground brush for level 2 headers
Header2MarginThicknessGets or sets the margin for level 2 headers
Header3FontSizedoubleGets or sets the font size for level 3 headers
Header3FontWeightFontWeightGets or sets the font weight to use for level 3 headers
Header3ForegroundBrushGets or sets the foreground brush for level 3 headers
Header3MarginThicknessGets or sets the margin for level 3 headers
Header4FontSizedoubleGets or sets the font size for level 4 headers
Header4FontWeightFontWeightGets or sets the font weight to use for level 4 headers
Header4ForegroundBrushGets or sets the foreground brush for level 4 headers
Header4MarginThicknessGets or sets the margin for level 4 headers
Header5FontSizedoubleGets or sets the font size for level 5 headers
Header5FontWeightFontWeightGets or sets the font weight to use for level 5 headers
Header5ForegroundBrushGets or sets the foreground brush for level 5 headers
Header5MarginThicknessGets or sets the margin for level 5 headers
Header6FontSizedoubleGets or sets the font size for level 6 headers
Header6FontWeightFontWeightGets or sets the font weight to use for level 6 headers
Header6ForegroundBrushGets or sets the foreground brush for level 6 headers
Header6MarginThicknessGets or sets the margin for level 6 headers
HorizontalRuleBrushBrushGets or sets the brush used to render a horizontal rule. If this is null, then HorizontalRuleBrush is used
HorizontalRuleMarginThicknessGets or sets the margin used for horizontal rules
HorizontalRuleThicknessdoubleGets or sets the vertical thickness of the horizontal rule
ImageMaxHeightdoubleGets or sets the MaxHeight for images
ImageMaxWidthdoubleGets or sets the MaxWidth for images
ImageStretchStretchGets or sets the stretch used for images
InlineCodeBackgroundBrushGets or sets the foreground brush for inline code.
InlineCodeBorderBrushBrushGets or sets the border brush for inline code
InlineCodeBorderThicknessThicknessGets or sets the thickness of the border for inline code
InlineCodeFontFamilyFontFamilyGets or sets the font used to display code. If this is null, then Windows.UI.Xaml.Media.FontFamily is used
InlineCodePaddingThicknessGets or sets the padding for inline code
InlineCodeMarginThicknessGets or sets the margin for inline code
IsTextSelectionEnabledboolGets or sets a value indicating whether text selection is enabled
LinkForegroundBrushGets or sets the brush used to render links. If this is null, then Foreground is used
ListBulletSpacingdoubleGets or sets the space between the list item bullets/numbers and the list item content
ListGutterWidthdoubleGets or sets the width of the space used by list item bullets/numbers
ListMarginThicknessGets or sets the margin used by lists
ParagraphMarginThicknessGets or sets the margin used for paragraphs
ParagraphLineHeightintGets or sets the line hegiht used for paragraphs.
QuoteBackgroundBrushGets or sets the brush used to fill the background of a quote block
QuoteBorderBrushBrushGets or sets the brush used to render a quote border. If this is null, then QuoteBorderBrush is used
QuoteBorderThicknessThicknessGets or sets the thickness of quote borders.
QuoteForegroundBrushGets or sets the brush used to render the text inside a quote block. If this is null, then Foreground is used
QuoteMarginThicknessGets or sets the space outside of quote borders
QuotePaddingThicknessGets or sets the space between the quote border and the text
SchemeListstring(separated by comma)Gets or sets the custom SchemeList to render a URL.
TableBorderBrushBrushGets or sets the brush used to render table borders. If this is null, then TableBorderBrush is used
TableBorderThicknessdoubleGets or sets the thickness of any table borders
TableCellPaddingThicknessGets or sets the padding inside each cell
TableMarginThicknessGets or sets the margin used by tables
YamlBoderThicknessThicknessGets or sets the thickness of any yaml header borders.
YamlBoderBrushBrushGets or sets the brush used to render yaml heade borders. If this is null, then TableBorderBrush is used
TextstringGets or sets the markdown text to display
TextWrappingTextWrappingGets or sets the word wrapping behavior
UriPrefixstringGets or sets the Prefix of Uri
UseSyntaxHighlightingboolGets or sets a value indicating whether to use Syntax Highlighting on Code
WrapCodeBlockboolGets or sets a value indicating whether to Wrap the Code Block or use a Horizontal Scroll

Events

EventsDescription
CodeBlockResolvingFired when a Code Block is being Rendered. The default implementation is to output the CodeBlock as Plain Text. You must set Handled to true in order to process your changes
ImageClickedFired when an image element in the markdown was tapped
ImageResolvingFired when an image from the markdown document needs to be resolved. The default implementation is basically. You must set Handled to true in order to process your changes
LinkClickedFired when a link element in the markdown was tapped
MarkdownRenderedFired when the text is done parsing and formatting. Fires each time the markdown is rendered

LinkClicked

Use this event to handle clicking on links for Markdown, by default the MarkdownTextBlock does not handle Clicking on Links.

ImageClicked

Use this event to handle clicking on images for Markdown, by default the MarkdownTextBlock does not handle Clicking on Images.

ImageResolving

Use this event to customize how images in the markdown document are resolved.

Set the ImageResolvingEventArgs.Image property to the image that should be shown in the rendered markdown document.
Also don't forget to set the ImageResolvingEventArgs.Handled flag to true, otherwise your custom image will not be used.

This event also supports loading the image in an asynchronous way.
Just request a Deferral which you complete when you're done.

CodeBlockResolving

Use this event to customise how Code Block text is rendered, this is useful for providing Cusom Syntax Highlighting. Built in Syntax Highlighting is already provided with UseSyntaxHighlighting.

Manipulate the Inline Collection, and then set e.Handled to true, otherwise the changes won't be processed.

Rendering

You can customise the rendering of the MarkdownTextBlock, by inheriting from MarkdownRenderer and setting it as the renderer:

This will likely require intimate knowledge of the implementation of the MarkdownRenderer, take a look at the following:

Markdown

Sample Project

MarkdownTextBlock Sample Page Source. You can see this in action in the Windows Community Toolkit Sample App.

Default Template

MarkdownTextBlock XAML File is the XAML template used in the toolkit for the default styling.

Requirements

Device familyUniversal, 10.0.16299.0 or higher
NamespaceMicrosoft.Toolkit.Uwp.UI.Controls
NuGet packageMicrosoft.Toolkit.Uwp.UI.Controls

API

Related Topics