Skip to content

Commit bf80275

Browse files
author
msftbot[bot]
authored
Changed TextBoxExtensions.PlaceHolder property name (#3810)
## PR Type What kind of change does this PR introduce? <!-- Please uncomment one or more that apply to this PR. --> - Refactoring with API changes <!-- - Bugfix --> <!-- - Feature --> <!-- - Code style update (formatting) --> <!-- - Refactoring (no functional changes, no api changes) --> <!-- - Build or CI related changes --> <!-- - Documentation content changes --> <!-- - Sample app changes --> <!-- - Other... Please describe: --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> The mask placeholder property is called `PlaceHolder`. ## What is the new behavior? <!-- Describe how was this issue resolved or changed? --> It's now called `MaskPlaceholder` instead. ## PR Checklist Please check if your PR fulfills the following requirements: - [X] Tested code with current [supported SDKs](../readme.md#supported) - [X] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link --> - [X] Sample in sample app has been added / updated (for bug fixes / features) - [X] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets) - [X] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/windows-toolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc... - [X] Tests for the changes have been added (for bug fixes / features) (if applicable) - [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*) - [X] Contains **NO** breaking changes
2 parents b553bfb + 41c4472 commit bf80275

File tree

6 files changed

+34
-35
lines changed

6 files changed

+34
-35
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,34 @@
3333
</Grid.RowDefinitions>
3434

3535
<TextBox Name="AlphaTextBox"
36-
ui:TextBoxMask.Mask="9a9a-a9a*"
36+
ui:TextBoxExtensions.Mask="9a9a-a9a*"
3737
Header="Text box with Mask 9a9a-a9a* (9 allows from 0 to 9, a allow from a to Z and * allows both a and 9)"
3838
HeaderTemplate="{StaticResource HeaderTemplate}"
3939
Style="{StaticResource MaskedTextBoxStyle}"
40-
Text="TextBoxMask" />
40+
Text="TextBoxMask" />
4141

4242
<TextBox Grid.Row="1"
43-
ui:TextBoxMask.Mask="+1999-9999"
44-
ui:TextBoxMask.PlaceHolder=" "
43+
ui:TextBoxExtensions.Mask="+1999-9999"
44+
ui:TextBoxExtensions.MaskPlaceholder=" "
4545
Header="Text box with Mask +1999-9999 and placeHolder as space (placeholder represents the characters the user can change on runtime)"
4646
HeaderTemplate="{StaticResource HeaderTemplate}"
4747
Style="{StaticResource MaskedTextBoxStyle}" />
4848

4949
<TextBox Grid.Row="2"
50-
ui:TextBoxMask.Mask="+\964 799 999 9999"
50+
ui:TextBoxExtensions.Mask="+\964 799 999 9999"
5151
Header="Text box with Mask +964 799 999 9999 (Notice how we escape the first 9 with a backslash)"
5252
HeaderTemplate="{StaticResource HeaderTemplate}"
5353
Style="{StaticResource MaskedTextBoxStyle}" />
5454

5555
<TextBox Grid.Row="3"
56-
ui:TextBoxMask.Mask="99\\99\\9999"
56+
ui:TextBoxExtensions.Mask="99\\99\\9999"
5757
Header="Text box with Mask 99\99\9999 (You can escape a backslash with another backslash)"
5858
HeaderTemplate="{StaticResource HeaderTemplate}"
5959
Style="{StaticResource MaskedTextBoxStyle}" />
6060

6161
<TextBox Grid.Row="4"
62-
ui:TextBoxMask.CustomMask="5:[1-5],c:[a-c]"
63-
ui:TextBoxMask.Mask="a5c-5c*9"
62+
ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
63+
ui:TextBoxExtensions.Mask="a5c-5c*9"
6464
Header="Text box with CustomMask in case you want to define your own variable character like a, 9 and *. Mask: a5c-5c*9, 5: [1-5], c: [a-c]"
6565
HeaderTemplate="{StaticResource HeaderTemplate}"
6666
Style="{StaticResource MaskedTextBoxStyle}" />

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<TextBox ui:TextBoxExtensions.Mask="9a9a--a9a*"/>
1212

1313
<TextBox ui:TextBoxExtensions.Mask="+1999-9999"
14-
ui:TextBoxExtensions.PlaceHolder=" " />
14+
ui:TextBoxExtensions.MaskPlaceholder=" " />
1515

1616
<TextBox ui:TextBoxExtensions.Mask="+\964 799 999 9999"
17-
ui:TextBoxExtensions.PlaceHolder=" " />
17+
ui:TextBoxExtensions.MaskPlaceholder=" " />
1818

1919
<TextBox ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
2020
ui:TextBoxExtensions.Mask="a5c-5c*9" />

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxRegex/TextBoxRegex.bind

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,70 +34,70 @@
3434

3535
<StackPanel Margin="10,10,10,0">
3636
<TextBox Name="PhoneNumberValidator"
37-
ui:TextBoxRegex.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
37+
ui:TextBoxExtensions.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
3838
Header="Text box with Regex extension for phone number, validation occurs on TextChanged"
3939
HeaderTemplate="{StaticResource HeaderTemplate}"
4040
Style="{StaticResource TextBoxRegexStyle}" />
4141
<StackPanel Orientation="Horizontal">
4242
<TextBlock Text="Is Valid: " />
43-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
43+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
4444
</StackPanel>
4545

4646
</StackPanel>
4747

4848
<StackPanel Grid.Row="1"
49-
Margin="10,10,10,0">
49+
Margin="10,10,10,0">
5050
<TextBox Name="CharactValidator"
51-
ui:TextBoxRegex.ValidationMode="Dynamic"
52-
ui:TextBoxRegex.ValidationType="Characters"
51+
ui:TextBoxExtensions.ValidationMode="Dynamic"
52+
ui:TextBoxExtensions.ValidationType="Characters"
5353
Header="Text box with ValidationType=Characters, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
5454
HeaderTemplate="{StaticResource HeaderTemplate}"
5555
Style="{StaticResource TextBoxRegexStyle}"
5656
Text="abcdef" />
5757
<StackPanel Orientation="Horizontal">
5858
<TextBlock Text="Is Valid: " />
59-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
59+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
6060
</StackPanel>
6161
</StackPanel>
6262

6363
<StackPanel Grid.Row="2"
64-
Margin="10,10,10,0">
64+
Margin="10,10,10,0">
6565
<TextBox Name="EmailValidator"
66-
ui:TextBoxRegex.ValidationType="Email"
66+
ui:TextBoxExtensions.ValidationType="Email"
6767
Header="Text box with ValidationType=Email, validation occurs on TextChanged"
6868
HeaderTemplate="{StaticResource HeaderTemplate}"
6969
Style="{StaticResource TextBoxRegexStyle}" />
7070
<StackPanel Orientation="Horizontal">
7171
<TextBlock Text="Is Valid: " />
72-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
72+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
7373
</StackPanel>
7474
</StackPanel>
7575

7676
<StackPanel Grid.Row="3"
7777
Margin="10,10,10,0">
7878
<TextBox Name="DecimalValidatorForce"
79-
ui:TextBoxRegex.ValidationMode="Forced"
80-
ui:TextBoxRegex.ValidationType="Decimal"
79+
ui:TextBoxExtensions.ValidationMode="Forced"
80+
ui:TextBoxExtensions.ValidationType="Decimal"
8181
Header="Text box with ValidationType=Decimal, validation occurs on TextChanged and force occurs on lose focus with ValidationMode=Force (333,111 or 333.111)"
8282
HeaderTemplate="{StaticResource HeaderTemplate}"
8383
Style="{StaticResource TextBoxRegexStyle}" />
8484
<StackPanel Orientation="Horizontal">
8585
<TextBlock Text="Is Valid: " />
86-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
86+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
8787
</StackPanel>
8888
</StackPanel>
8989

9090
<StackPanel Grid.Row="4"
9191
Margin="10,10,10,0">
9292
<TextBox Name="NumberValidatorDynamic"
93-
ui:TextBoxRegex.ValidationMode="Dynamic"
94-
ui:TextBoxRegex.ValidationType="Number"
93+
ui:TextBoxExtensions.ValidationMode="Dynamic"
94+
ui:TextBoxExtensions.ValidationType="Number"
9595
Header="Text box with ValidationType=Number, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
9696
HeaderTemplate="{StaticResource HeaderTemplate}"
9797
Style="{StaticResource TextBoxRegexStyle}" />
9898
<StackPanel Orientation="Horizontal">
9999
<TextBlock Text="Is Valid: " />
100-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
100+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
101101
</StackPanel>
102102
</StackPanel>
103103

Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/SurfaceDialOptions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Windows.UI.Input;
66
using Windows.UI.Xaml;
77
using Windows.UI.Xaml.Controls;
8-
using Windows.UI.Xaml.Input;
98

109
namespace Microsoft.Toolkit.Uwp.UI
1110
{

Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static void Textbox_Loaded(object sender, RoutedEventArgs e)
4949
return;
5050
}
5151

52-
var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string;
52+
var placeHolderValue = textbox.GetValue(MaskPlaceholderProperty) as string;
5353
if (string.IsNullOrEmpty(placeHolderValue))
5454
{
5555
throw new ArgumentException("PlaceHolder can't be null or empty");
@@ -152,7 +152,7 @@ private static void Textbox_GotFocus_Mask(object sender, RoutedEventArgs e)
152152
{
153153
var textbox = (TextBox)sender;
154154
var mask = textbox?.GetValue(MaskProperty) as string;
155-
var placeHolderValue = textbox?.GetValue(PlaceHolderProperty) as string;
155+
var placeHolderValue = textbox?.GetValue(MaskPlaceholderProperty) as string;
156156
var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary<char, string>;
157157
if (string.IsNullOrWhiteSpace(mask) ||
158158
representationDictionary == null ||
@@ -194,7 +194,7 @@ private static async void Textbox_Paste(object sender, TextControlPasteEventArgs
194194
var textbox = (TextBox)sender;
195195
var mask = textbox.GetValue(MaskProperty) as string;
196196
var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary<char, string>;
197-
var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string;
197+
var placeHolderValue = textbox.GetValue(MaskPlaceholderProperty) as string;
198198
if (string.IsNullOrWhiteSpace(mask) ||
199199
representationDictionary == null ||
200200
string.IsNullOrEmpty(placeHolderValue))
@@ -262,7 +262,7 @@ private static void Textbox_TextChanging(TextBox textbox, TextBoxTextChangingEve
262262
var escapedChars = textbox.GetValue(EscapedCharacterIndicesProperty) as List<int>;
263263

264264
var representationDictionary = textbox.GetValue(RepresentationDictionaryProperty) as Dictionary<char, string>;
265-
var placeHolderValue = textbox?.GetValue(PlaceHolderProperty) as string;
265+
var placeHolderValue = textbox?.GetValue(MaskPlaceholderProperty) as string;
266266
var oldText = textbox.GetValue(OldTextProperty) as string;
267267
var oldSelectionStart = (int)textbox.GetValue(OldSelectionStartProperty);
268268
var oldSelectionLength = (int)textbox.GetValue(OldSelectionLengthProperty);

Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Properties.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static partial class TextBoxExtensions
1919
/// <summary>
2020
/// Represents the mask place holder which represents the variable character that the user can edit in the textbox
2121
/// </summary>
22-
public static readonly DependencyProperty PlaceHolderProperty = DependencyProperty.RegisterAttached("PlaceHolder", typeof(string), typeof(TextBoxExtensions), new PropertyMetadata(DefaultPlaceHolder, InitTextBoxMask));
22+
public static readonly DependencyProperty MaskPlaceholderProperty = DependencyProperty.RegisterAttached("MaskPlaceholder", typeof(string), typeof(TextBoxExtensions), new PropertyMetadata(DefaultPlaceHolder, InitTextBoxMask));
2323

2424
/// <summary>
2525
/// Represents the custom mask that the user can create to add his own variable characters based on regex expression
@@ -60,19 +60,19 @@ public static void SetMask(TextBox obj, string value)
6060
/// </summary>
6161
/// <param name="obj">TextBox control</param>
6262
/// <returns>placeholder value</returns>
63-
public static string GetPlaceHolder(TextBox obj)
63+
public static string GetMaskPlaceholder(TextBox obj)
6464
{
65-
return (string)obj.GetValue(PlaceHolderProperty);
65+
return (string)obj.GetValue(MaskPlaceholderProperty);
6666
}
6767

6868
/// <summary>
6969
/// Sets placeholder property which represents the variable character that the user can edit in the textbox
7070
/// </summary>
7171
/// <param name="obj">TextBox Control</param>
7272
/// <param name="value">placeholder Value</param>
73-
public static void SetPlaceHolder(TextBox obj, string value)
73+
public static void SetMaskPlaceholder(TextBox obj, string value)
7474
{
75-
obj.SetValue(PlaceHolderProperty, value);
75+
obj.SetValue(MaskPlaceholderProperty, value);
7676
}
7777

7878
/// <summary>

0 commit comments

Comments
 (0)