diff --git a/components/MarkdownTextBlock/src/MarkdownConfig.cs b/components/MarkdownTextBlock/src/MarkdownConfig.cs index d04187c2d..99508f108 100644 --- a/components/MarkdownTextBlock/src/MarkdownConfig.cs +++ b/components/MarkdownTextBlock/src/MarkdownConfig.cs @@ -11,5 +11,7 @@ public record MarkdownConfig public ISVGRenderer? SVGRenderer { get; set; } public MarkdownThemes Themes { get; set; } = MarkdownThemes.Default; - public static MarkdownConfig Default = new(); + [ThreadStatic] + private static MarkdownConfig? _default; + public static MarkdownConfig Default => _default ??= new MarkdownConfig(); } diff --git a/components/MarkdownTextBlock/src/MarkdownTextBlock.Properties.cs b/components/MarkdownTextBlock/src/MarkdownTextBlock.Properties.cs index 06ad510cc..3307b1c67 100644 --- a/components/MarkdownTextBlock/src/MarkdownTextBlock.Properties.cs +++ b/components/MarkdownTextBlock/src/MarkdownTextBlock.Properties.cs @@ -15,7 +15,7 @@ public partial class MarkdownTextBlock nameof(Config), typeof(MarkdownConfig), typeof(MarkdownTextBlock), - new PropertyMetadata(new MarkdownConfig(), OnConfigChanged) + PropertyMetadata.Create(() => MarkdownConfig.Default, OnConfigChanged) ); /// diff --git a/components/MarkdownTextBlock/src/MarkdownThemes.cs b/components/MarkdownTextBlock/src/MarkdownThemes.cs index 21393cf21..d38edf660 100644 --- a/components/MarkdownTextBlock/src/MarkdownThemes.cs +++ b/components/MarkdownTextBlock/src/MarkdownThemes.cs @@ -14,7 +14,9 @@ namespace CommunityToolkit.WinUI.Controls; public sealed class MarkdownThemes : DependencyObject { - internal static MarkdownThemes Default { get; } = new(); + [ThreadStatic] + private static MarkdownThemes? _default; + internal static MarkdownThemes Default => _default ??= new MarkdownThemes(); public Thickness Padding { get; set; } = new(8);