From e3c97e6875765c205e931b8ed5dbcf2a33bb9a3f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 5 Mar 2021 22:37:08 +0100 Subject: [PATCH 1/3] Renamed TextBoxExtensions.PlaceHolder property --- .../Extensions/TextBox/SurfaceDialOptions.cs | 1 - .../TextBox/TextBoxExtensions.Mask.Internals.cs | 8 ++++---- .../TextBox/TextBoxExtensions.Mask.Properties.cs | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/SurfaceDialOptions.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/SurfaceDialOptions.cs index 9e0293bd147..783948f4605 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/SurfaceDialOptions.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/SurfaceDialOptions.cs @@ -5,7 +5,6 @@ using Windows.UI.Input; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Input; namespace Microsoft.Toolkit.Uwp.UI { diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs index 1974f27aa4b..83ad996b2d1 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs @@ -49,7 +49,7 @@ private static void Textbox_Loaded(object sender, RoutedEventArgs e) return; } - var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string; + var placeHolderValue = textbox.GetValue(MaskPlaceholderCharacterProperty) as string; if (string.IsNullOrEmpty(placeHolderValue)) { throw new ArgumentException("PlaceHolder can't be null or empty"); @@ -152,7 +152,7 @@ private static void Textbox_GotFocus_Mask(object sender, RoutedEventArgs e) { var textbox = (TextBox)sender; var mask = textbox?.GetValue(MaskProperty) as string; - var placeHolderValue = textbox?.GetValue(PlaceHolderProperty) as string; + var placeHolderValue = textbox?.GetValue(MaskPlaceholderCharacterProperty) as string; var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary; if (string.IsNullOrWhiteSpace(mask) || representationDictionary == null || @@ -194,7 +194,7 @@ private static async void Textbox_Paste(object sender, TextControlPasteEventArgs var textbox = (TextBox)sender; var mask = textbox.GetValue(MaskProperty) as string; var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary; - var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string; + var placeHolderValue = textbox.GetValue(MaskPlaceholderCharacterProperty) as string; if (string.IsNullOrWhiteSpace(mask) || representationDictionary == null || string.IsNullOrEmpty(placeHolderValue)) @@ -262,7 +262,7 @@ private static void Textbox_TextChanging(TextBox textbox, TextBoxTextChangingEve var escapedChars = textbox.GetValue(EscapedCharacterIndicesProperty) as List; var representationDictionary = textbox.GetValue(RepresentationDictionaryProperty) as Dictionary; - var placeHolderValue = textbox?.GetValue(PlaceHolderProperty) as string; + var placeHolderValue = textbox?.GetValue(MaskPlaceholderCharacterProperty) as string; var oldText = textbox.GetValue(OldTextProperty) as string; var oldSelectionStart = (int)textbox.GetValue(OldSelectionStartProperty); var oldSelectionLength = (int)textbox.GetValue(OldSelectionLengthProperty); diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs index 1388c422206..194f36dc486 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs @@ -19,7 +19,7 @@ public static partial class TextBoxExtensions /// /// Represents the mask place holder which represents the variable character that the user can edit in the textbox /// - public static readonly DependencyProperty PlaceHolderProperty = DependencyProperty.RegisterAttached("PlaceHolder", typeof(string), typeof(TextBoxExtensions), new PropertyMetadata(DefaultPlaceHolder, InitTextBoxMask)); + public static readonly DependencyProperty MaskPlaceholderCharacterProperty = DependencyProperty.RegisterAttached("MaskPlaceholderCharacter", typeof(string), typeof(TextBoxExtensions), new PropertyMetadata(DefaultPlaceHolder, InitTextBoxMask)); /// /// Represents the custom mask that the user can create to add his own variable characters based on regex expression @@ -62,7 +62,7 @@ public static void SetMask(TextBox obj, string value) /// placeholder value public static string GetPlaceHolder(TextBox obj) { - return (string)obj.GetValue(PlaceHolderProperty); + return (string)obj.GetValue(MaskPlaceholderCharacterProperty); } /// @@ -72,7 +72,7 @@ public static string GetPlaceHolder(TextBox obj) /// placeholder Value public static void SetPlaceHolder(TextBox obj, string value) { - obj.SetValue(PlaceHolderProperty, value); + obj.SetValue(MaskPlaceholderCharacterProperty, value); } /// From 6b4985ec33296b573a0caa63abe7e7f0c8e006cf Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 5 Mar 2021 22:46:13 +0100 Subject: [PATCH 2/3] Updated TextBoxExtensions sample pages --- .../SamplePages/TextBoxMask/TextBoxMask.bind | 16 +++++----- .../TextBoxMask/TextBoxMaskPage.xaml | 4 +-- .../TextBoxRegex/TextBoxRegex.bind | 30 +++++++++---------- .../TextBoxExtensions.Mask.Properties.cs | 4 +-- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind index 916f71a7ca1..1a66aadc66e 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind @@ -33,34 +33,34 @@ + Text="TextBoxMask" /> diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml index 3cff6b59f4b..f1f5db7d5f3 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml @@ -11,10 +11,10 @@ + ui:TextBoxExtensions.MaskPlaceholderCharacter=" " /> + ui:TextBoxExtensions.MaskPlaceholderCharacter=" " /> diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxRegex/TextBoxRegex.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxRegex/TextBoxRegex.bind index 5d651fef082..fea97e83720 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxRegex/TextBoxRegex.bind +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxRegex/TextBoxRegex.bind @@ -34,70 +34,70 @@ - + + Margin="10,10,10,0"> - + + Margin="10,10,10,0"> - + - + - + diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs index 194f36dc486..c5f596702dc 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs @@ -60,7 +60,7 @@ public static void SetMask(TextBox obj, string value) /// /// TextBox control /// placeholder value - public static string GetPlaceHolder(TextBox obj) + public static string GetMaskPlaceholderCharacter(TextBox obj) { return (string)obj.GetValue(MaskPlaceholderCharacterProperty); } @@ -70,7 +70,7 @@ public static string GetPlaceHolder(TextBox obj) /// /// TextBox Control /// placeholder Value - public static void SetPlaceHolder(TextBox obj, string value) + public static void SetMaskPlaceholderCharacter(TextBox obj, string value) { obj.SetValue(MaskPlaceholderCharacterProperty, value); } From 41c44729f8af77a4df8b657870c78e978f30d41e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 5 Mar 2021 22:54:10 +0100 Subject: [PATCH 3/3] Renamed mask placeholder property --- .../SamplePages/TextBoxMask/TextBoxMask.bind | 2 +- .../SamplePages/TextBoxMask/TextBoxMaskPage.xaml | 4 ++-- .../TextBox/TextBoxExtensions.Mask.Internals.cs | 8 ++++---- .../TextBox/TextBoxExtensions.Mask.Properties.cs | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind index 1a66aadc66e..f2d69fc56db 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind @@ -41,7 +41,7 @@ diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml index f1f5db7d5f3..148c5933b5d 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml @@ -11,10 +11,10 @@ + ui:TextBoxExtensions.MaskPlaceholder=" " /> + ui:TextBoxExtensions.MaskPlaceholder=" " /> diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs index 83ad996b2d1..18dee56289e 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs @@ -49,7 +49,7 @@ private static void Textbox_Loaded(object sender, RoutedEventArgs e) return; } - var placeHolderValue = textbox.GetValue(MaskPlaceholderCharacterProperty) as string; + var placeHolderValue = textbox.GetValue(MaskPlaceholderProperty) as string; if (string.IsNullOrEmpty(placeHolderValue)) { throw new ArgumentException("PlaceHolder can't be null or empty"); @@ -152,7 +152,7 @@ private static void Textbox_GotFocus_Mask(object sender, RoutedEventArgs e) { var textbox = (TextBox)sender; var mask = textbox?.GetValue(MaskProperty) as string; - var placeHolderValue = textbox?.GetValue(MaskPlaceholderCharacterProperty) as string; + var placeHolderValue = textbox?.GetValue(MaskPlaceholderProperty) as string; var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary; if (string.IsNullOrWhiteSpace(mask) || representationDictionary == null || @@ -194,7 +194,7 @@ private static async void Textbox_Paste(object sender, TextControlPasteEventArgs var textbox = (TextBox)sender; var mask = textbox.GetValue(MaskProperty) as string; var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary; - var placeHolderValue = textbox.GetValue(MaskPlaceholderCharacterProperty) as string; + var placeHolderValue = textbox.GetValue(MaskPlaceholderProperty) as string; if (string.IsNullOrWhiteSpace(mask) || representationDictionary == null || string.IsNullOrEmpty(placeHolderValue)) @@ -262,7 +262,7 @@ private static void Textbox_TextChanging(TextBox textbox, TextBoxTextChangingEve var escapedChars = textbox.GetValue(EscapedCharacterIndicesProperty) as List; var representationDictionary = textbox.GetValue(RepresentationDictionaryProperty) as Dictionary; - var placeHolderValue = textbox?.GetValue(MaskPlaceholderCharacterProperty) as string; + var placeHolderValue = textbox?.GetValue(MaskPlaceholderProperty) as string; var oldText = textbox.GetValue(OldTextProperty) as string; var oldSelectionStart = (int)textbox.GetValue(OldSelectionStartProperty); var oldSelectionLength = (int)textbox.GetValue(OldSelectionLengthProperty); diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs index c5f596702dc..67a007c5ccf 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs @@ -19,7 +19,7 @@ public static partial class TextBoxExtensions /// /// Represents the mask place holder which represents the variable character that the user can edit in the textbox /// - public static readonly DependencyProperty MaskPlaceholderCharacterProperty = DependencyProperty.RegisterAttached("MaskPlaceholderCharacter", typeof(string), typeof(TextBoxExtensions), new PropertyMetadata(DefaultPlaceHolder, InitTextBoxMask)); + public static readonly DependencyProperty MaskPlaceholderProperty = DependencyProperty.RegisterAttached("MaskPlaceholder", typeof(string), typeof(TextBoxExtensions), new PropertyMetadata(DefaultPlaceHolder, InitTextBoxMask)); /// /// Represents the custom mask that the user can create to add his own variable characters based on regex expression @@ -60,9 +60,9 @@ public static void SetMask(TextBox obj, string value) /// /// TextBox control /// placeholder value - public static string GetMaskPlaceholderCharacter(TextBox obj) + public static string GetMaskPlaceholder(TextBox obj) { - return (string)obj.GetValue(MaskPlaceholderCharacterProperty); + return (string)obj.GetValue(MaskPlaceholderProperty); } /// @@ -70,9 +70,9 @@ public static string GetMaskPlaceholderCharacter(TextBox obj) /// /// TextBox Control /// placeholder Value - public static void SetMaskPlaceholderCharacter(TextBox obj, string value) + public static void SetMaskPlaceholder(TextBox obj, string value) { - obj.SetValue(MaskPlaceholderCharacterProperty, value); + obj.SetValue(MaskPlaceholderProperty, value); } ///