From 913ef1a0bd9abc997a9438948aba2ef85ca739ad Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 3 Mar 2026 16:04:48 +0800 Subject: [PATCH] Improve style setter property checks for CaretBrush/Foreground Updated logic to compare dependency property objects directly instead of using string property names when identifying and manipulating CaretBrush and Foreground setters. This enhances robustness and reduces risk of errors from string comparisons. --- Flow.Launcher.Core/Resource/Theme.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index fe0d0e970..445d033c7 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -217,9 +217,9 @@ namespace Flow.Launcher.Core.Resource style.Setters.Add(new Setter(Control.FontStretchProperty, fontStretch)); // Set caret brush (retain existing logic) - var caretBrushProperty = style.Setters.OfType().Where(x => x.Property.Name == "CaretBrush")? + var caretBrushProperty = style.Setters.OfType().Where(x => x.Property == TextBoxBase.CaretBrushProperty)? .FirstOrDefault(); - var foregroundPropertyValue = style.Setters.OfType().Where(x => x.Property.Name == "Foreground") + var foregroundPropertyValue = style.Setters.OfType().Where(x => x.Property == Control.ForegroundProperty) .Select(x => x.Value).FirstOrDefault(); if (caretBrushProperty != null && foregroundPropertyValue != null) { @@ -245,6 +245,7 @@ namespace Flow.Launcher.Core.Resource style.Setters.Remove(setter); } + // Add New font setter style.Setters.Add(new Setter(TextBlock.FontFamilyProperty, fontFamily)); style.Setters.Add(new Setter(TextBlock.FontStyleProperty, fontStyle)); style.Setters.Add(new Setter(TextBlock.FontWeightProperty, fontWeight));