Markdown viewer for .Net WinForms

Introduction

Last week I wanted to add a Wiki to a .Net WinForms project I was working on and surprisingly didn’t seem to find an obvious and simple candidate. With (a lot) of help from ChatGPT I found two great resources which I could use to make one for myself:

  1. Markdig: for rendering Markdown using HTML
  2. WebView2: the Microsoft Edge-based rendering engine

With these two controls, a small amount of manual, coding, and a lot of flow-coding, I put together a library:

  • CDS.Markdown

In here is a single control:

  • CDS.Markdown.MarkdownViewer

It looks like this:

And at runtime, it renders like this:


How to use

  1. In your .Net 6/8 or Framework project, add the CDS.Markdown package from the NuGet package manager.
  2. Drag and drop a MarkdownViewer control from the toolbox onto your form.
  3. Add a line of code to load a markdown file.

For example:

protected async override void OnShown(EventArgs e)
{
    base.OnShown(e);
    await markdownViewer1.LoadMarkdownAsync("Wiki/index.md");
}

In the project you must make sure your markdown files are copied at compile time. For example:

That’s it!


More information

  • See the demo project, available on GitHub.
  • Package information on NuGet.
  • Refer to the Markdown guide for more information on Markdown formatting.

Most of the code and effort was done by GPT4.1 via Copilot in Visual Studio 2022, using Agent mode.


Flow-coding

Flow-coding sits somewhere between conventional coding and vibe-coding. Unlike vibe-coding, which leans heavily on prompt engineering, flow-coding keeps the human deeply engaged in shaping the code while AI tools like Copilot act as an active partner. It’s an ongoing conversation where ideas and code evolve together.

DevExpress PropertyGridControl changes not detected using Ribbon button (by default)

TLDR; set CausesValidation to true on a ribbon bar button to make sure any controls that support validation, such as property grids, have their changes committed and validated before moving focus to the button.

I recently had a problem trying to verify data on a property grid – any changes I had just made, where the cursor was still active on the grid editor, were not committed when I clicked a ribbon bar button. For example, when my application starts it looks like this:

And when I click ‘Display person’ I get a message box:

However, if I change the ‘Age’ property and click the ‘Display person’ button without first hitting the enter key, I see this:

The DevExpress button click does not result in the changes being noticed before displaying the message box because the CausesValidation property is false:

Note that the built-in .Net Framework button has this property set to true by default.

Changing the property to true causes the property grid’s validation to be performed which includes attempting to commit any live changes to the underlying object, the Person instance.

And adding a message box to the property grid’s validating event makes the change and sequence of events more visible:

First:

Then:

Written this post because I figured this out about 2 years ago and today forgot everything !