diff --git a/src/MainDemo.Wpf/Fields.xaml b/src/MainDemo.Wpf/Fields.xaml
index 68481e35ea..be5fe9088a 100644
--- a/src/MainDemo.Wpf/Fields.xaml
+++ b/src/MainDemo.Wpf/Fields.xaml
@@ -148,7 +148,14 @@
Style="{StaticResource MaterialDesignFloatingHintTextBox}"
Text="Some Text" />
+
+
+
+
+
@@ -182,18 +189,18 @@
-
+
+ VerticalScrollBarVisibility="Auto" />
@@ -690,12 +697,11 @@
-
+
+ materialDesign:HintAssist.HintPaddingBrush="Chocolate"
+ Style="{StaticResource MaterialDesignOutlinedTextBox}" />
@@ -704,7 +710,7 @@
-
+
-
+
@@ -774,7 +780,7 @@
-
+
diff --git a/src/MaterialDesign3.Demo.Wpf/Fields.xaml b/src/MaterialDesign3.Demo.Wpf/Fields.xaml
index 6bcfd37bc6..fdf7a2c3bd 100644
--- a/src/MaterialDesign3.Demo.Wpf/Fields.xaml
+++ b/src/MaterialDesign3.Demo.Wpf/Fields.xaml
@@ -43,7 +43,7 @@
-
+
@@ -54,6 +54,7 @@
+
+
+
+
+
-
(bool)element.GetValue(IncludeSpellingSuggestionsProperty);
+ ///
+ /// Allow triple click to select all text in a TextBox.
+ ///
+ public static readonly DependencyProperty SelectAllOnTripleClickProperty =
+ DependencyProperty.RegisterAttached(
+ "SelectAllOnTripleClick",
+ typeof(bool),
+ typeof(TextFieldAssist),
+ new PropertyMetadata(false, OnSelectAllOnTripleClickChanged));
+
+ public static bool GetSelectAllOnTripleClick(TextBoxBase obj) =>
+ (bool)obj.GetValue(SelectAllOnTripleClickProperty);
+
+ public static void SetSelectAllOnTripleClick(TextBoxBase obj, bool value) =>
+ obj.SetValue(SelectAllOnTripleClickProperty, value);
+
+ private static void OnSelectAllOnTripleClickChanged(
+ DependencyObject d,
+ DependencyPropertyChangedEventArgs e)
+ {
+ if (d is TextBoxBase textBox)
+ {
+ if ((bool)e.NewValue)
+ textBox.PreviewMouseLeftButtonDown += TextBox_PreviewMouseLeftButtonDown;
+ else
+ textBox.PreviewMouseLeftButtonDown -= TextBox_PreviewMouseLeftButtonDown;
+ }
+
+ static void TextBox_PreviewMouseLeftButtonDown(
+ object sender,
+ MouseButtonEventArgs e)
+ {
+ if (e.ClickCount == 3 && sender is TextBoxBase textBox)
+ {
+ textBox.SelectAll();
+ e.Handled = true;
+ }
+ }
+ }
+
///
/// SuffixText dependency property
///
diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml
index e80e3ef2e7..670cb90621 100644
--- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml
+++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml
@@ -629,6 +629,7 @@
+
diff --git a/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs
index 7a248ca4ef..3c004f7759 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs
@@ -497,6 +497,49 @@ public async Task TextBox_MultiLineAndFixedHeight_RespectsVerticalContentAlignme
await Assert.That(await contentGrid.GetVerticalAlignment()).IsEqualTo(expectedFloatingHintAlignment);
}
+ [Test]
+ public async Task TextBox_WithSelectAllOnTripleClick_False_DoesNotSelectAllText()
+ {
+ var textBox = await LoadXaml($$"""
+
+ """);
+
+ await textBox.LeftClick(Position.LeftCenter, xOffset: 30);
+ await textBox.LeftClick(Position.LeftCenter, xOffset: 30);
+ await textBox.LeftClick(Position.LeftCenter, xOffset: 30);
+
+ await Wait.For(async () =>
+ {
+ string? selectedText = await textBox.GetSelectedText();
+
+ await Assert.That(selectedText).IsEqualTo("Some ");
+ });
+ }
+
+ [Test]
+ public async Task TextBox_WithDefaultSelectAllOnTripleClick_SelectsAllText()
+ {
+ var textBox = await LoadXaml($$"""
+
+ """);
+
+ await textBox.LeftClick(Position.LeftCenter, xOffset: 30);
+ await textBox.LeftClick(Position.LeftCenter, xOffset: 30);
+ await textBox.LeftClick(Position.LeftCenter, xOffset: 30);
+
+ await Wait.For(async () =>
+ {
+ string? selectedText = await textBox.GetSelectedText();
+
+ await Assert.That(selectedText).IsEqualTo("Some text to select");
+ });
+ }
+
[Test]
[Description("Issue 3176")]
public async Task ValidationErrorTemplate_WithChangingErrors_UpdatesValidation()