From 4ce3dd2d39e31a46d29a714e0ffff7bee1f5e76a Mon Sep 17 00:00:00 2001 From: Andrew Stein Date: Sun, 5 Jul 2026 20:21:56 -0500 Subject: [PATCH] Add TextColor property to set base text color at runtime The internal plumbing (TextControlBoxDesign.TextColor, DesignHelper.TextColorBrush/CreateColorResources, and TextRenderer drawing body text with TextColorBrush) already existed; the only way to change it was to replace the whole Design object. Expose a granular public TextColor property on CoreTextControlBox and the public TextControlBox wrapper that updates the design color, rebuilds the brush and redraws, mirroring the other granular properties. --- TextControlBox/Core/CoreTextControlBox.xaml.cs | 15 +++++++++++++++ TextControlBox/TextControlBox.cs | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/TextControlBox/Core/CoreTextControlBox.xaml.cs b/TextControlBox/Core/CoreTextControlBox.xaml.cs index 0e26204..98ac107 100644 --- a/TextControlBox/Core/CoreTextControlBox.xaml.cs +++ b/TextControlBox/Core/CoreTextControlBox.xaml.cs @@ -1076,6 +1076,21 @@ public TextControlBoxDesign Design set => designHelper.Design = value; } + public Windows.UI.Color TextColor + { + get => designHelper._Design.TextColor; + set + { + if (designHelper._Design.TextColor.Equals(value)) + return; + + designHelper._Design.TextColor = value; + designHelper.ColorResourcesCreated = false; + textRenderer.NeedsUpdateTextLayout = true; + canvasUpdateManager.UpdateAll(); + } + } + public bool ShowLineNumbers { get => lineNumberManager._ShowLineNumbers; diff --git a/TextControlBox/TextControlBox.cs b/TextControlBox/TextControlBox.cs index 3bcb65c..1332f6e 100644 --- a/TextControlBox/TextControlBox.cs +++ b/TextControlBox/TextControlBox.cs @@ -788,6 +788,19 @@ public TextControlBoxDesign Design set => coreTextBox.Design = value; } + /// + /// Gets or sets the color of the editor body text. + /// + /// + /// This is the base text color. When syntax highlighting is enabled, per-token colors from the + /// active still take precedence for highlighted tokens. + /// + public Windows.UI.Color TextColor + { + get => coreTextBox.TextColor; + set => coreTextBox.TextColor = value; + } + /// /// Gets or sets a value indicating whether line numbers should be displayed in the textbox. ///