Skip to content

Commit 913ef1a

Browse files
committed
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.
1 parent aff6b20 commit 913ef1a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ private static void SetFontProperties(Style style, FontFamily fontFamily, FontSt
217217
style.Setters.Add(new Setter(Control.FontStretchProperty, fontStretch));
218218

219219
// Set caret brush (retain existing logic)
220-
var caretBrushProperty = style.Setters.OfType<Setter>().Where(x => x.Property.Name == "CaretBrush")?
220+
var caretBrushProperty = style.Setters.OfType<Setter>().Where(x => x.Property == TextBoxBase.CaretBrushProperty)?
221221
.FirstOrDefault();
222-
var foregroundPropertyValue = style.Setters.OfType<Setter>().Where(x => x.Property.Name == "Foreground")
222+
var foregroundPropertyValue = style.Setters.OfType<Setter>().Where(x => x.Property == Control.ForegroundProperty)
223223
.Select(x => x.Value).FirstOrDefault();
224224
if (caretBrushProperty != null && foregroundPropertyValue != null)
225225
{
@@ -245,6 +245,7 @@ private static void SetFontProperties(Style style, FontFamily fontFamily, FontSt
245245
style.Setters.Remove(setter);
246246
}
247247

248+
// Add New font setter
248249
style.Setters.Add(new Setter(TextBlock.FontFamilyProperty, fontFamily));
249250
style.Setters.Add(new Setter(TextBlock.FontStyleProperty, fontStyle));
250251
style.Setters.Add(new Setter(TextBlock.FontWeightProperty, fontWeight));

0 commit comments

Comments
 (0)