diff --git a/docs/release-notes/1.6.0.md b/docs/release-notes/1.6.0.md
index eb73d6bc47..687899513c 100644
--- a/docs/release-notes/1.6.0.md
+++ b/docs/release-notes/1.6.0.md
@@ -34,6 +34,12 @@
- `Badged` control has now a different look when disabled. thx [@xxMUROxx](https://github.com/xxMUROxx)
+ Adds new brush to light and dark themes `MahApps.Metro.Brushes.Badged.DisabledBackgroundBrush`
- Don't catch `TextChangedEvent` in `NumericUpDown` [#3066](https://github.com/MahApps/MahApps.Metro/pull/3066) [@Silv3rcircl3](https://github.com/Silv3rcircl3)
+- `Watermark` fixes and improvements
+ + Fix right aligned floating watermark.
+ + Use `TextBoxHelper.Watermark` for `HotKeyBox` instead own DependencyProperty (marked as obsolete).
+ + Allow `TextBoxHelper.AutoWatermark` for `HotKey` DependencyProperty of `HotKeyBox`.
+ + New `TextBoxHelper.WatermarkTrimming` attached property to set the text trimming behavior to employ when (floating) watermark overflows the content area. thx to [@amkuchta](https://github.com/amkuchta)
+ + New `TextBoxHelper.WatermarkWrapping` attached property (only for `TextBox`) to set how the watermark should wrap text. Default is binded to `TextWrapping` property. thx to [@amkuchta](https://github.com/amkuchta)
## Breaking Change
@@ -87,3 +93,7 @@ More informations about the reason of this decision can be found here:
- [#3017](https://github.com/MahApps/MahApps.Metro/issues/3017) SplitButton with custom ItemTemplate - Source change does not always update layout
- [#2977](https://github.com/MahApps/MahApps.Metro/issues/2977) Badge must have a different look when disabled
- [#2937](https://github.com/MahApps/MahApps.Metro/issues/2937) Fuzzy button outline [#3064](https://github.com/MahApps/MahApps.Metro/pull/3064) [@n00bje](https://github.com/n00bje)
+- [#3067](https://github.com/MahApps/MahApps.Metro/issues/3067) Right aligned floating Watermark goes behind clear button
+- [#3068](https://github.com/MahApps/MahApps.Metro/issues/3068) AutoWatermark attached property has no effect on HotKeyBox
+- [#2884](https://github.com/MahApps/MahApps.Metro/issues/2884) [Feature Request] Watermark Trimming
+- [#2889](https://github.com/MahApps/MahApps.Metro/issues/2889) [Feature Request] Watermark Wrapping
diff --git a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TextBoxHelper.cs b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TextBoxHelper.cs
index cbcbe453f3..50bdc24159 100644
--- a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TextBoxHelper.cs
+++ b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TextBoxHelper.cs
@@ -43,6 +43,8 @@ public class TextBoxHelper
public static readonly DependencyProperty IsMonitoringProperty = DependencyProperty.RegisterAttached("IsMonitoring", typeof(bool), typeof(TextBoxHelper), new UIPropertyMetadata(false, OnIsMonitoringChanged));
public static readonly DependencyProperty WatermarkProperty = DependencyProperty.RegisterAttached("Watermark", typeof(string), typeof(TextBoxHelper), new UIPropertyMetadata(string.Empty));
public static readonly DependencyProperty WatermarkAlignmentProperty = DependencyProperty.RegisterAttached("WatermarkAlignment", typeof(TextAlignment), typeof(TextBoxHelper), new FrameworkPropertyMetadata(TextAlignment.Left, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits));
+ public static readonly DependencyProperty WatermarkTrimmingProperty = DependencyProperty.RegisterAttached("WatermarkTrimming", typeof(TextTrimming), typeof(TextBoxHelper), new FrameworkPropertyMetadata(TextTrimming.None, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender));
+ public static readonly DependencyProperty WatermarkWrappingProperty = DependencyProperty.RegisterAttached("WatermarkWrapping", typeof(TextWrapping), typeof(TextBoxHelper), new FrameworkPropertyMetadata(TextWrapping.NoWrap, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UseFloatingWatermarkProperty = DependencyProperty.RegisterAttached("UseFloatingWatermark", typeof(bool), typeof(TextBoxHelper), new FrameworkPropertyMetadata(false, ButtonCommandOrClearTextChanged));
public static readonly DependencyProperty TextLengthProperty = DependencyProperty.RegisterAttached("TextLength", typeof(int), typeof(TextBoxHelper), new UIPropertyMetadata(0));
public static readonly DependencyProperty ClearTextButtonProperty = DependencyProperty.RegisterAttached("ClearTextButton", typeof(bool), typeof(TextBoxHelper), new FrameworkPropertyMetadata(false, ButtonCommandOrClearTextChanged));
@@ -85,6 +87,7 @@ public class TextBoxHelper
{ typeof(TextBox), TextBox.TextProperty },
{ typeof(ComboBox), Selector.SelectedItemProperty },
{ typeof(NumericUpDown), NumericUpDown.ValueProperty },
+ { typeof(HotKeyBox), HotKeyBox.HotKeyProperty },
{ typeof(DatePicker), DatePicker.SelectedDateProperty },
{ typeof(TimePicker), TimePickerBase.SelectedTimeProperty },
{ typeof(DateTimePicker), DateTimePicker.SelectedDateProperty }
@@ -112,6 +115,7 @@ public static void SetIsSpellCheckContextMenuEnabled(UIElement element, bool val
[AttachedPropertyBrowsableForType(typeof(DatePicker))]
[AttachedPropertyBrowsableForType(typeof(TimePickerBase))]
[AttachedPropertyBrowsableForType(typeof(NumericUpDown))]
+ [AttachedPropertyBrowsableForType(typeof(HotKeyBox))]
public static bool GetAutoWatermark(DependencyObject element)
{
return (bool)element.GetValue(AutoWatermarkProperty);
@@ -428,6 +432,7 @@ public static void SetIsMonitoring(DependencyObject obj, bool value)
[AttachedPropertyBrowsableForType(typeof(DatePicker))]
[AttachedPropertyBrowsableForType(typeof(TimePickerBase))]
[AttachedPropertyBrowsableForType(typeof(NumericUpDown))]
+ [AttachedPropertyBrowsableForType(typeof(HotKeyBox))]
public static string GetWatermark(DependencyObject obj)
{
return (string)obj.GetValue(WatermarkProperty);
@@ -451,6 +456,7 @@ public static void SetWatermark(DependencyObject obj, string value)
[AttachedPropertyBrowsableForType(typeof(DatePicker))]
[AttachedPropertyBrowsableForType(typeof(TimePickerBase))]
[AttachedPropertyBrowsableForType(typeof(NumericUpDown))]
+ [AttachedPropertyBrowsableForType(typeof(HotKeyBox))]
public static TextAlignment GetWatermarkAlignment(DependencyObject obj)
{
return (TextAlignment)obj.GetValue(WatermarkAlignmentProperty);
@@ -466,16 +472,75 @@ public static TextAlignment GetWatermarkAlignment(DependencyObject obj)
[AttachedPropertyBrowsableForType(typeof(DatePicker))]
[AttachedPropertyBrowsableForType(typeof(TimePickerBase))]
[AttachedPropertyBrowsableForType(typeof(NumericUpDown))]
+ [AttachedPropertyBrowsableForType(typeof(HotKeyBox))]
public static void SetWatermarkAlignment(DependencyObject obj, TextAlignment value)
{
obj.SetValue(WatermarkAlignmentProperty, value);
}
+ ///
+ /// Gets the text trimming behavior to employ when watermark overflows the content area.
+ ///
+ ///
+ /// One of the values that specifies the text trimming behavior to employ. The default is .
+ ///
+ [Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(TextBoxBase))]
+ [AttachedPropertyBrowsableForType(typeof(PasswordBox))]
+ [AttachedPropertyBrowsableForType(typeof(ComboBox))]
+ [AttachedPropertyBrowsableForType(typeof(DatePicker))]
+ [AttachedPropertyBrowsableForType(typeof(TimePickerBase))]
+ [AttachedPropertyBrowsableForType(typeof(NumericUpDown))]
+ [AttachedPropertyBrowsableForType(typeof(HotKeyBox))]
+ public static TextTrimming GetWatermarkTrimming(DependencyObject obj)
+ {
+ return (TextTrimming)obj.GetValue(WatermarkTrimmingProperty);
+ }
+
+ ///
+ /// Sets the text trimming behavior to employ when watermark overflows the content area.
+ ///
+ [Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(TextBoxBase))]
+ [AttachedPropertyBrowsableForType(typeof(PasswordBox))]
+ [AttachedPropertyBrowsableForType(typeof(ComboBox))]
+ [AttachedPropertyBrowsableForType(typeof(DatePicker))]
+ [AttachedPropertyBrowsableForType(typeof(TimePickerBase))]
+ [AttachedPropertyBrowsableForType(typeof(NumericUpDown))]
+ [AttachedPropertyBrowsableForType(typeof(HotKeyBox))]
+ public static void SetWatermarkTrimming(DependencyObject obj, TextTrimming value)
+ {
+ obj.SetValue(WatermarkTrimmingProperty, value);
+ }
+
+ ///
+ /// Gets how the watermark should wrap text.
+ ///
+ /// One of the values. The default is .
+ ///
+ [Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(TextBoxBase))]
+ public static TextWrapping GetWatermarkWrapping(DependencyObject obj)
+ {
+ return (TextWrapping)obj.GetValue(WatermarkWrappingProperty);
+ }
+
+ ///
+ /// Sets how the watermark should wrap text.
+ ///
+ [Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(TextBoxBase))]
+ public static void SetWatermarkWrapping(DependencyObject obj, TextWrapping value)
+ {
+ obj.SetValue(WatermarkWrappingProperty, value);
+ }
+
[Category(AppName.MahApps)]
[AttachedPropertyBrowsableForType(typeof(TextBoxBase))]
[AttachedPropertyBrowsableForType(typeof(PasswordBox))]
[AttachedPropertyBrowsableForType(typeof(ComboBox))]
[AttachedPropertyBrowsableForType(typeof(NumericUpDown))]
+ [AttachedPropertyBrowsableForType(typeof(HotKeyBox))]
public static bool GetUseFloatingWatermark(DependencyObject obj)
{
return (bool)obj.GetValue(UseFloatingWatermarkProperty);
diff --git a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/HotKeyBox.cs b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/HotKeyBox.cs
index c984537518..b254086b4b 100644
--- a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/HotKeyBox.cs
+++ b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/HotKeyBox.cs
@@ -38,9 +38,11 @@ public bool AreModifierKeysRequired
set { SetValue(AreModifierKeysRequiredProperty, value); }
}
+ [Obsolete("This property will be deleted in the next release. Instead use TextBoxHelper.Watermark attached property.")]
public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register(
"Watermark", typeof(string), typeof(HotKeyBox), new PropertyMetadata(default(string)));
+ [Obsolete("This property will be deleted in the next release. Instead use TextBoxHelper.Watermark attached property.")]
public string Watermark
{
get { return (string) GetValue(WatermarkProperty); }
diff --git a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.ComboBox.xaml b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.ComboBox.xaml
index 4733b97e6b..202706a470 100644
--- a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.ComboBox.xaml
+++ b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.ComboBox.xaml
@@ -76,11 +76,11 @@
Style="{DynamicResource MahApps.Metro.Styles.MetroWatermarkTextBlock}"
Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}"
Visibility="Collapsed" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
@@ -239,7 +242,8 @@
Foreground="{TemplateBinding Foreground}"
Style="{DynamicResource MahApps.Metro.Styles.MetroWatermarkTextBlock}"
Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
- TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
diff --git a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.PasswordBox.xaml b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.PasswordBox.xaml
index 7ba3aa6b60..84c09d4110 100644
--- a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.PasswordBox.xaml
+++ b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.PasswordBox.xaml
@@ -185,11 +185,11 @@
Style="{DynamicResource MahApps.Metro.Styles.MetroWatermarkTextBlock}"
Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}"
Visibility="Collapsed" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
+
@@ -101,11 +102,12 @@
Style="{DynamicResource MahApps.Metro.Styles.MetroWatermarkTextBlock}"
Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}"
+ TextWrapping="{TemplateBinding Controls:TextBoxHelper.WatermarkWrapping}"
Visibility="Collapsed" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />
+ TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
+ TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}" />