From d70af2472ce4dd89d54755bc686b41c9fc686ab4 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Fri, 9 Jan 2026 15:03:30 +0100 Subject: [PATCH 01/22] Adding cornerradius to image --- ...MarkdownTextBlockCustomThemeSample.xaml.cs | 7 +- .../MarkdownTextBlockCustomThemeSampleBase.cs | 11 + .../samples/ThemeOptionsPane.xaml | 460 +++++++++--------- .../samples/ThemeOptionsPane.xaml.cs | 2 + .../MarkdownTextBlock/src/MarkdownThemes.cs | 1 + .../src/TextElements/MyImage.cs | 11 +- 6 files changed, 269 insertions(+), 223 deletions(-) diff --git a/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSample.xaml.cs b/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSample.xaml.cs index 9a335dd8d..afdca385a 100644 --- a/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSample.xaml.cs +++ b/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSample.xaml.cs @@ -9,6 +9,7 @@ namespace MarkdownTextBlockExperiment.Samples; /// /// A sample demonstrating custom theming options for the MarkdownTextBlock control with live editing. /// +/// [ToolkitSample(id: nameof(MarkdownTextBlockCustomThemeSample), "Custom Theme", description: "A sample showcasing custom theming options with live editing for headings, code blocks, quotes, tables, and more.")] public sealed partial class MarkdownTextBlockCustomThemeSample : MarkdownTextBlockCustomThemeSampleBase { @@ -34,12 +35,16 @@ This sample demonstrates the **custom theming** capabilities of the `MarkdownTex ## Images -Images can be styled with max width, max height, and stretch options. Notice how the text flows naturally without any gaps above or below the image: +Images can be styled with max width, max height, corner radius, and stretch options. Notice how the text flows naturally without any gaps above or below the image: ![Windows Terminal](https://devblogs.microsoft.com/commandline/wp-content/uploads/sites/33/2025/11/0.96-Social-media-image-V2-1024x536.webp) The image above automatically scales to respect the max width setting while maintaining its aspect ratio. Text continues to flow seamlessly below it. +![Shortcut Conflict](https://devblogs.microsoft.com/commandline/wp-content/uploads/sites/33/2025/09/ShortcutConflict.png) + +Here's another image showing how corner radius can be applied to give images rounded corners. + ## Code Blocks ```csharp diff --git a/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSampleBase.cs b/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSampleBase.cs index c1c49e5d2..ab6c6a83a 100644 --- a/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSampleBase.cs +++ b/components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSampleBase.cs @@ -101,6 +101,9 @@ public abstract partial class MarkdownTextBlockCustomThemeSampleBase : Page public static readonly DependencyProperty ImageStretchIndexProperty = DependencyProperty.Register(nameof(ImageStretchIndex), typeof(int), typeof(MarkdownTextBlockCustomThemeSampleBase), new PropertyMetadata(0)); + public static readonly DependencyProperty ImageCornerRadiusProperty = + DependencyProperty.Register(nameof(ImageCornerRadius), typeof(double), typeof(MarkdownTextBlockCustomThemeSampleBase), new PropertyMetadata(0d)); + public static readonly DependencyProperty BoldFontWeightIndexProperty = DependencyProperty.Register(nameof(BoldFontWeightIndex), typeof(int), typeof(MarkdownTextBlockCustomThemeSampleBase), new PropertyMetadata(0)); @@ -283,6 +286,12 @@ public int ImageStretchIndex set => SetValue(ImageStretchIndexProperty, value); } + public double ImageCornerRadius + { + get => (double)GetValue(ImageCornerRadiusProperty); + set => SetValue(ImageCornerRadiusProperty, value); + } + public int BoldFontWeightIndex { get => (int)GetValue(BoldFontWeightIndexProperty); @@ -426,6 +435,7 @@ public MarkdownThemes CreateThemes() ImageMaxWidth = ImageMaxWidth, ImageMaxHeight = ImageMaxHeight, ImageStretch = ImageStretchOptions[ImageStretchIndex], + ImageCornerRadius = new CornerRadius(ImageCornerRadius), BoldFontWeight = BoldFontWeights[BoldFontWeightIndex], @@ -470,6 +480,7 @@ public void ResetToDefaults() ImageMaxWidth = 0; ImageMaxHeight = 0; ImageStretchIndex = 0; + ImageCornerRadius = 0; BoldFontWeightIndex = 0; diff --git a/components/MarkdownTextBlock/samples/ThemeOptionsPane.xaml b/components/MarkdownTextBlock/samples/ThemeOptionsPane.xaml index 4946ef686..18752229a 100644 --- a/components/MarkdownTextBlock/samples/ThemeOptionsPane.xaml +++ b/components/MarkdownTextBlock/samples/ThemeOptionsPane.xaml @@ -1,44 +1,46 @@ - - + + - -