From 4a0f66e51975338697c94453bc4375c27f4dc1d5 Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Wed, 3 Jun 2026 23:21:19 +0800
Subject: [PATCH] enhance: close #1777
---
.../Themes/Styles/Base/TreeViewBaseStyle.xaml | 1 +
.../HandyControl_Net_40/Themes/Theme.xaml | 5 ++++
.../Controls/Attach/VisualElement.cs | 23 +++++++++++++++----
.../Themes/Styles/Base/DataGridBaseStyle.xaml | 2 ++
.../Themes/Styles/Base/ListBoxBaseStyle.xaml | 1 +
.../Themes/Styles/Base/ListViewBaseStyle.xaml | 1 +
.../Themes/Styles/Base/TreeViewBaseStyle.xaml | 1 +
.../HandyControl_Shared/Themes/Theme.xaml | 5 ++++
8 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml b/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml
index 25e782ac..c5d941b4 100644
--- a/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml
+++ b/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml
@@ -72,6 +72,7 @@
+
diff --git a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
index 36719a7d..406ede18 100644
--- a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
+++ b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
@@ -9252,6 +9252,7 @@
+
@@ -9358,6 +9359,7 @@
+
@@ -11621,6 +11623,7 @@
+
@@ -11855,6 +11858,7 @@
+
@@ -11907,6 +11911,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/VisualElement.cs b/src/Shared/HandyControl_Shared/Controls/Attach/VisualElement.cs
index cb36d6e8..2bba96ee 100644
--- a/src/Shared/HandyControl_Shared/Controls/Attach/VisualElement.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Attach/VisualElement.cs
@@ -1,12 +1,14 @@
using System.Windows;
using System.Windows.Media;
+using HandyControl.Data;
namespace HandyControl.Controls;
public class VisualElement
{
public static readonly DependencyProperty HighlightBrushProperty = DependencyProperty.RegisterAttached(
- "HighlightBrush", typeof(Brush), typeof(VisualElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
+ "HighlightBrush", typeof(Brush), typeof(VisualElement),
+ new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));
public static void SetHighlightBrush(DependencyObject element, Brush value)
=> element.SetValue(HighlightBrushProperty, value);
@@ -15,7 +17,8 @@ public class VisualElement
=> (Brush) element.GetValue(HighlightBrushProperty);
public static readonly DependencyProperty HighlightBackgroundProperty = DependencyProperty.RegisterAttached(
- "HighlightBackground", typeof(Brush), typeof(VisualElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
+ "HighlightBackground", typeof(Brush), typeof(VisualElement),
+ new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));
public static void SetHighlightBackground(DependencyObject element, Brush value)
=> element.SetValue(HighlightBackgroundProperty, value);
@@ -24,7 +27,8 @@ public class VisualElement
=> (Brush) element.GetValue(HighlightBackgroundProperty);
public static readonly DependencyProperty HighlightBorderBrushProperty = DependencyProperty.RegisterAttached(
- "HighlightBorderBrush", typeof(Brush), typeof(VisualElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
+ "HighlightBorderBrush", typeof(Brush), typeof(VisualElement),
+ new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));
public static void SetHighlightBorderBrush(DependencyObject element, Brush value)
=> element.SetValue(HighlightBorderBrushProperty, value);
@@ -33,7 +37,8 @@ public class VisualElement
=> (Brush) element.GetValue(HighlightBorderBrushProperty);
public static readonly DependencyProperty HighlightForegroundProperty = DependencyProperty.RegisterAttached(
- "HighlightForeground", typeof(Brush), typeof(VisualElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
+ "HighlightForeground", typeof(Brush), typeof(VisualElement),
+ new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));
public static void SetHighlightForeground(DependencyObject element, Brush value)
=> element.SetValue(HighlightForegroundProperty, value);
@@ -49,4 +54,14 @@ public class VisualElement
public static string GetText(DependencyObject element)
=> (string) element.GetValue(TextProperty);
+
+ public static readonly DependencyProperty StaysHighlightedProperty = DependencyProperty.RegisterAttached(
+ "StaysHighlighted", typeof(bool), typeof(VisualElement),
+ new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.Inherits));
+
+ public static void SetStaysHighlighted(DependencyObject element, bool value)
+ => element.SetValue(StaysHighlightedProperty, value);
+
+ public static bool GetStaysHighlighted(DependencyObject element)
+ => (bool) element.GetValue(StaysHighlightedProperty);
}
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DataGridBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DataGridBaseStyle.xaml
index 94ca191c..e46179e1 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DataGridBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DataGridBaseStyle.xaml
@@ -85,6 +85,7 @@
+
@@ -138,6 +139,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml
index 819023dc..c067cafc 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml
@@ -35,6 +35,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListViewBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListViewBaseStyle.xaml
index 9255a8a9..90d7c9ae 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListViewBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListViewBaseStyle.xaml
@@ -70,6 +70,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TreeViewBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TreeViewBaseStyle.xaml
index 2786dd59..d87c72c5 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TreeViewBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TreeViewBaseStyle.xaml
@@ -72,6 +72,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Theme.xaml b/src/Shared/HandyControl_Shared/Themes/Theme.xaml
index a666883d..903e01c3 100644
--- a/src/Shared/HandyControl_Shared/Themes/Theme.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Theme.xaml
@@ -9371,6 +9371,7 @@
+
@@ -9477,6 +9478,7 @@
+
@@ -11740,6 +11742,7 @@
+
@@ -11991,6 +11994,7 @@
+
@@ -12043,6 +12047,7 @@
+