You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you don't set the MarkdownConfig should it be set to MarkdownConfig.Default by default? Right now, if you don't set MarkdownConfig it doesn't render. If that's the expected behavior, then you can ignore this.
If you don't set the MarkdownConfig should it be set to MarkdownConfig.Default by default? Right now, if you don't set MarkdownConfig it doesn't render. If that's the expected behavior, then you can ignore this.
Yeah we'll address that in #611. Essentially no property should be "required" to just render some text.
MarkdownTextBlock throws an exception with a particular Markdown example:
```
Will it ~blend~ crash?
```
Full Stack:
System.NullReferenceException: Object reference not set to an instance of an object.
at CommunityToolkit.WinUI.Controls.TextElements.MyCodeBlock..ctor(CodeBlock codeBlock, MarkdownConfig config)
at CommunityToolkit.WinUI.Controls.Renderers.ObjectRenderers.CodeBlockRenderer.Write(WinUIRenderer renderer, CodeBlock obj)
at Markdig.Renderers.MarkdownObjectRenderer`2.Write(RendererBase renderer, MarkdownObject obj)
at Markdig.Renderers.RendererBase.Write(MarkdownObject obj)
at Markdig.Renderers.RendererBase.WriteChildren(ContainerBlock containerBlock)
at Markdig.Renderers.RendererBase.Write(MarkdownObject obj)
at CommunityToolkit.WinUI.Controls.Renderers.WinUIRenderer.Render(MarkdownObject markdownObject)
at CommunityToolkit.WinUI.Controls.MarkdownTextBlock.ApplyText(Boolean rerender)
at CommunityToolkit.WinUI.Controls.MarkdownTextBlock.OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at ABI.Microsoft.UI.Xaml.PropertyChangedCallback.Do_Abi_Invoke(IntPtr thisPtr, IntPtr d, IntPtr e)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IDependencyObjectMethods.SetValue(IObjectReference _obj, DependencyProperty dp, Object value)
at CommunityToolkit.WinUI.Controls.MarkdownTextBlock.set_Text(String value)
at Microsoft.CmdPal.UI.Pages.ShellPage.XamlBindingSetters.Set_CommunityToolkit_WinUI_Controls_MarkdownTextBlock_Text(MarkdownTextBlock obj, String value, String targetNullValue) in X:\source\jp-PowerToys\src\modules\cmdpal\Microsoft.CmdPal.UI\obj\x64\Debug\Pages\ShellPage.g.cs:line 103
at Microsoft.CmdPal.UI.Pages.ShellPage.ShellPage_obj1_Bindings.Update_ViewModel_Details_Body(String obj, Int32 phase) in X:\source\jp-PowerToys\src\modules\cmdpal\Microsoft.CmdPal.UI\obj\x64\Debug\Pages\ShellPage.g.cs:line 3024
at Microsoft.CmdPal.UI.Pages.ShellPage.ShellPage_obj1_Bindings.Update_ViewModel_Details(DetailsViewModel obj, Int32 phase) in X:\source\jp-PowerToys\src\modules\cmdpal\Microsoft.CmdPal.UI\obj\x64\Debug\Pages\ShellPage.g.cs:line 2966
at Microsoft.CmdPal.UI.Pages.ShellPage.ShellPage_obj1_Bindings.ShellPage_obj1_BindingsTracking.PropertyChanged_ViewModel(Object sender, PropertyChangedEventArgs e) in X:\source\jp-PowerToys\src\modules\cmdpal\Microsoft.CmdPal.UI\obj\x64\Debug\Pages\ShellPage.g.cs:line 3237
at Microsoft.CmdPal.Core.ViewModels.ShellViewModel.set_Details(DetailsViewModel value) in X:\source\jp-PowerToys\src\modules\cmdpal\Core\Microsoft.CmdPal.Core.ViewModels\obj\g\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator\Microsoft.CmdPal.Core.ViewModels.ShellViewModel.g.cs:line 46
at Microsoft.CmdPal.UI.Pages.ShellPage.<>c__DisplayClass24_0.<Receive>b__1() in X:\source\jp-PowerToys\src\modules\cmdpal\Microsoft.CmdPal.UI\Pages\ShellPage.xaml.cs:line 284
at CommunityToolkit.WinUI.DispatcherQueueTimerExtensions.Timer_Tick(Object sender, Object e)
at WinRT._EventSource_global__Windows_Foundation_TypedEventHandler_global__Microsoft_UI_Dispatching_DispatcherQueueTimer__object_.EventState.<GetEventInvoke>b__1_0(DispatcherQueueTimer sender, Object args)
at WinRT.GenericTypeInstantiations.Windows_Foundation_TypedEventHandler_2_Microsoft_UI_Dispatching_DispatcherQueueTimer__object.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr args)
Hi, the MarkdownTextBlock apparently ignores the config setting IsTextSelectionEnabled="False". I set this to false on every MTB I added in my app and I can still easily select the text.
Do I use this wrong, is there a bug or is it not implemented yet?
We tried MarkdownTextBlock for rendering streamed chat replies in a WinUI 3 sample, and ran into a few bugs along the way.
Tested with 0.1.251217-build.2433 from nuget.org on WinAppSDK 2.0, and all five look present on main too (looks like maybe the component hasn't changed since January). They're also still there in #785 as of dae6b7c.
Inline code inside bold or italic is dropped.**`git status`** shows what changed renders as " shows what changed". MyEmphasisInline.AddChild only handles MyInlineText and nested MyEmphasisInline, so anything else is silently ignored. From the code, links and line breaks inside emphasis would be dropped the same way.
<https://...> autolinks vanish by default. "See https://example.com for details" renders as "See for details". CommonMark parses these autolinks even without UseAutoLinks, but AutoLinkInlineRenderer is only registered when it's on, so the text has nowhere to go.
Code blocks get padded with blank lines. A one-line fenced block shows three empty lines under it. MyCodeBlock loops over codeBlock.Lines.Lines, the StringLineGroup's backing array, spare capacity included (the same loop as the NRE above). Looping to Lines.Count, or using Lines.ToString(), fixes it.
Images are downloaded from any URL in the text by default. Without an ImageProvider, MyImage fetches the URL with a new HttpClient as soon as it loads, and <img> tags do the same unless DisableHtml is set. The only way to stop Markdown images is DisableLinks, which turns off links too. Each Text change also re-renders and refetches: one streamed reply fetched the same image 12 times. For apps that render untrusted text, like model output, an opt-in or a separate DisableImages would help. (Possibly related to Possible memory leak when reloading images in MarkdownTextBlock #772.)
DisableHtml and DisableLinks are registered under the wrong names.DependencyProperty.Register(nameof(DisableHtmlProperty), ...) registers "DisableHtmlProperty" rather than "DisableHtml". Setting them in XAML works, since that goes through the CLR property, but anything that looks them up by name wouldn't find them.
We ended up writing a small Markdig renderer for our sample instead, but wanted to note these findings. (It didn't look like there were any discrete issues for them)
Three layout bugs in MarkdownTextBlock, seen in PowerToys Command Palette's details pane (package CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock 0.1.261027-build.2704). The code they point to is unchanged on main (1665678).
1. Long inline code is clipped instead of wrapping
`pwsh -NoProfile -Command "git -C 'C:\src\some-repo' pull; if ($LASTEXITCODE -ne 0) { Write-Host 'git pull FAILED' -ForegroundColor Red; Read-Host 'Press Enter to close' } else { Write-Host 'Pull OK' }"`
Actual: the span is drawn on one line and cut off at the control's right edge; the rest cannot be seen. Expected: it wraps like the surrounding text.
Cause:MyInlineCode puts a TextBlock (default TextWrapping.NoWrap) in a Border in an InlineUIContainer, which is laid out as one unbreakable box. Related: no font family is set on that TextBlock and MarkdownThemes has no inline-code font family, so inline code is not monospaced.
2. Nothing inside a blockquote wraps
> A quoted paragraph with a long line that should wrap inside the control like ordinary text does.> ```> Get-ChildItem -Path C:\Users\Example\Documents\Projects -Recurse -Filter *.cs | Sort-Object Length -Descending> ```
Actual: both the paragraph and the code block run past the right edge and are clipped. Expected: they wrap, as they do outside a quote.
Cause:MyQuote sizes both grid columns Auto, so the content column measures its RichTextBlock with unlimited width. A * width for the content column would let it wrap.
3. Code blocks have blank lines below their text
```one line```
Actual: a one-line block is as tall as four lines; longer blocks get extra empty lines too. Expected: the block fits its lines.
Cause:MyCodeBlock loops over codeBlock.Lines.Lines, which is Markdig's backing array of StringLineGroup and is larger than the line count. The unused slots become empty paragraphs. Looping to codeBlock.Lines.Count fixes it.
Activity
rstewa commentedon Nov 29, 2024
If you don't set the
MarkdownConfigshould it be set toMarkdownConfig.Defaultby default? Right now, if you don't setMarkdownConfigit doesn't render. If that's the expected behavior, then you can ignore this.nerocui commentedon Nov 29, 2024
Yeah we'll address that in #611. Essentially no property should be "required" to just render some text.
samrueby commentedon Oct 2, 2025
MarkdownTextBlockthrows an exception with a particular Markdown example:Full Stack:
Originally reported in PowerToys: microsoft/PowerToys#42142 (comment)
jiripolasek commentedon Oct 2, 2025
Details to the issue above: ^
codeBlock.Lines.Linesin MyCodeBlock.cs:78 is null.Labs-Windows/components/MarkdownTextBlock/src/TextElements/MyCodeBlock.cs
Lines 78 to 87 in c19046b
CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock, version 0.1.250910-build.2249
reproducible on main c19046b
Easily reproducible in Labs sample app, by entering MD code block quotes ``` into the MarkdownTextBlock sample editor.
PR #742 seems to hotfix the issue
Sella-GH commentedon Sep 5, 2026
Hi, the
MarkdownTextBlockapparently ignores the config settingIsTextSelectionEnabled="False". I set this tofalseon every MTB I added in my app and I can still easily select the text.Do I use this wrong, is there a bug or is it not implemented yet?
NuGet package: 0.1.260617-build.2640
.NET SDK: 10.0.400
jefgen commentedon Oct 14, 2026
Thank you very much for this experiment! 😊
We tried
MarkdownTextBlockfor rendering streamed chat replies in a WinUI 3 sample, and ran into a few bugs along the way.Tested with
0.1.251217-build.2433from nuget.org on WinAppSDK 2.0, and all five look present onmaintoo (looks like maybe the component hasn't changed since January). They're also still there in #785 as ofdae6b7c.**`git status`** shows what changedrenders as " shows what changed".MyEmphasisInline.AddChildonly handlesMyInlineTextand nestedMyEmphasisInline, so anything else is silently ignored. From the code, links and line breaks inside emphasis would be dropped the same way.<https://...>autolinks vanish by default. "See https://example.com for details" renders as "See for details". CommonMark parses these autolinks even withoutUseAutoLinks, butAutoLinkInlineRendereris only registered when it's on, so the text has nowhere to go.MyCodeBlockloops overcodeBlock.Lines.Lines, theStringLineGroup's backing array, spare capacity included (the same loop as the NRE above). Looping toLines.Count, or usingLines.ToString(), fixes it.ImageProvider,MyImagefetches the URL with a newHttpClientas soon as it loads, and<img>tags do the same unlessDisableHtmlis set. The only way to stop Markdown images isDisableLinks, which turns off links too. EachTextchange also re-renders and refetches: one streamed reply fetched the same image 12 times. For apps that render untrusted text, like model output, an opt-in or a separateDisableImageswould help. (Possibly related to Possible memory leak when reloading images in MarkdownTextBlock #772.)DisableHtmlandDisableLinksare registered under the wrong names.DependencyProperty.Register(nameof(DisableHtmlProperty), ...)registers "DisableHtmlProperty" rather than "DisableHtml". Setting them in XAML works, since that goes through the CLR property, but anything that looks them up by name wouldn't find them.We ended up writing a small Markdig renderer for our sample instead, but wanted to note these findings. (It didn't look like there were any discrete issues for them)
Thanks again!
(with help from 🤖)
BambinoSK commentedon Nov 30, 2026
Three layout bugs in MarkdownTextBlock, seen in PowerToys Command Palette's details pane (package
CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock0.1.261027-build.2704). The code they point to is unchanged onmain(1665678).1. Long inline code is clipped instead of wrapping
Actual: the span is drawn on one line and cut off at the control's right edge; the rest cannot be seen.
Expected: it wraps like the surrounding text.
Cause:
MyInlineCodeputs aTextBlock(defaultTextWrapping.NoWrap) in aBorderin anInlineUIContainer, which is laid out as one unbreakable box. Related: no font family is set on thatTextBlockandMarkdownThemeshas no inline-code font family, so inline code is not monospaced.2. Nothing inside a blockquote wraps
Actual: both the paragraph and the code block run past the right edge and are clipped.
Expected: they wrap, as they do outside a quote.
Cause:
MyQuotesizes both grid columnsAuto, so the content column measures itsRichTextBlockwith unlimited width. A*width for the content column would let it wrap.3. Code blocks have blank lines below their text
Actual: a one-line block is as tall as four lines; longer blocks get extra empty lines too.
Expected: the block fits its lines.
Cause:
MyCodeBlockloops overcodeBlock.Lines.Lines, which is Markdig's backing array ofStringLineGroupand is larger than the line count. The unused slots become empty paragraphs. Looping tocodeBlock.Lines.Countfixes it.