AIChatControl.MarkdownConvert Event
Allows you to convert Markdown-formatted response text to HTML before the AI Chat Control displays it.
Namespace: DevExpress.AIIntegration.WinForms.Chat
Assembly: DevExpress.AIIntegration.WinForms.Chat.v26.1.dll
NuGet Package: DevExpress.AIIntegration.WinForms.Chat
Declaration
[DXCategory("Events")]
public event EventHandler<AIChatControlMarkdownConvertEventArgs> MarkdownConvert
Event Data
The MarkdownConvert event's data class is DevExpress.AIIntegration.Blazor.Chat.WebView.AIChatControlMarkdownConvertEventArgs.
Remarks
To enable Markdown message rendering:
- Set the ContentFormat property to
Markdownto receive responses as Markdown. - Handle the
MarkdownConvertevent to convert Markdown text to HTML and make responses more readable and structured.
Warning
Always sanitize AI-generated content before rendering it in the UI.
Example
The following example enables Markdown message rendering. The example uses the Markdig Markdown processing library to convert Markdown text into HTML.
using DevExpress.AIIntegration.Blazor.Chat;
using DevExpress.AIIntegration.Blazor.Chat.WebView;
using Ganss.Xss;
using Markdig;
HtmlSanitizer sanitizer;
public Chat() {
InitializeComponent();
sanitizer = new HtmlSanitizer();
aiChatControl1.ContentFormat = ResponseContentFormat.Markdown;
aiChatControl1.MarkdownConvert += AiChatControl1_MarkdownConvert;
}
void AiChatControl1_MarkdownConvert(object sender, AIChatControlMarkdownConvertEventArgs e) {
// Convert Markdown to HTML.
string html = Markdown.ToHtml(e.MarkdownText);
// WARNING: The AI agent's content may be untrusted.
// Developers must sanitize all HTML before rendering to prevent XSS attacks.
string safeHtml = sanitizer.Sanitize(html);
// Assign sanitized HTML for rendering.
e.HtmlText = (MarkupString)safeHtml;
}
The following screenshot demonstrates the result:

Refer to the following help topic for additional information: AI Chat Control
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the MarkdownConvert event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.