Updated TextBoxExtensions sample pages

This commit is contained in:
Sergio Pedri 2021-03-05 22:46:13 +01:00
Родитель e3c97e6875
Коммит 6b4985ec33
4 изменённых файлов: 27 добавлений и 27 удалений

Просмотреть файл

@ -33,34 +33,34 @@
</Grid.RowDefinitions>
<TextBox Name="AlphaTextBox"
ui:TextBoxMask.Mask="9a9a-a9a*"
ui:TextBoxExtensions.Mask="9a9a-a9a*"
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)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}"
Text="TextBoxMask" />
Text="TextBoxMask" />
<TextBox Grid.Row="1"
ui:TextBoxMask.Mask="+1999-9999"
ui:TextBoxMask.PlaceHolder=" "
ui:TextBoxExtensions.Mask="+1999-9999"
ui:TextBoxExtensions.MaskPlaceholderCharacter=" "
Header="Text box with Mask +1999-9999 and placeHolder as space (placeholder represents the characters the user can change on runtime)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />
<TextBox Grid.Row="2"
ui:TextBoxMask.Mask="+\964 799 999 9999"
ui:TextBoxExtensions.Mask="+\964 799 999 9999"
Header="Text box with Mask +964 799 999 9999 (Notice how we escape the first 9 with a backslash)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />
<TextBox Grid.Row="3"
ui:TextBoxMask.Mask="99\\99\\9999"
ui:TextBoxExtensions.Mask="99\\99\\9999"
Header="Text box with Mask 99\99\9999 (You can escape a backslash with another backslash)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />
<TextBox Grid.Row="4"
ui:TextBoxMask.CustomMask="5:[1-5],c:[a-c]"
ui:TextBoxMask.Mask="a5c-5c*9"
ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
ui:TextBoxExtensions.Mask="a5c-5c*9"
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]"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource MaskedTextBoxStyle}" />

Просмотреть файл

@ -11,10 +11,10 @@
<TextBox ui:TextBoxExtensions.Mask="9a9a--a9a*"/>
<TextBox ui:TextBoxExtensions.Mask="+1999-9999"
ui:TextBoxExtensions.PlaceHolder=" " />
ui:TextBoxExtensions.MaskPlaceholderCharacter=" " />
<TextBox ui:TextBoxExtensions.Mask="+\964 799 999 9999"
ui:TextBoxExtensions.PlaceHolder=" " />
ui:TextBoxExtensions.MaskPlaceholderCharacter=" " />
<TextBox ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
ui:TextBoxExtensions.Mask="a5c-5c*9" />

Просмотреть файл

@ -34,70 +34,70 @@
<StackPanel Margin="10,10,10,0">
<TextBox Name="PhoneNumberValidator"
ui:TextBoxRegex.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
ui:TextBoxExtensions.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
Header="Text box with Regex extension for phone number, validation occurs on TextChanged"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="1"
Margin="10,10,10,0">
Margin="10,10,10,0">
<TextBox Name="CharactValidator"
ui:TextBoxRegex.ValidationMode="Dynamic"
ui:TextBoxRegex.ValidationType="Characters"
ui:TextBoxExtensions.ValidationMode="Dynamic"
ui:TextBoxExtensions.ValidationType="Characters"
Header="Text box with ValidationType=Characters, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}"
Text="abcdef" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="2"
Margin="10,10,10,0">
Margin="10,10,10,0">
<TextBox Name="EmailValidator"
ui:TextBoxRegex.ValidationType="Email"
ui:TextBoxExtensions.ValidationType="Email"
Header="Text box with ValidationType=Email, validation occurs on TextChanged"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="3"
Margin="10,10,10,0">
<TextBox Name="DecimalValidatorForce"
ui:TextBoxRegex.ValidationMode="Forced"
ui:TextBoxRegex.ValidationType="Decimal"
ui:TextBoxExtensions.ValidationMode="Forced"
ui:TextBoxExtensions.ValidationType="Decimal"
Header="Text box with ValidationType=Decimal, validation occurs on TextChanged and force occurs on lose focus with ValidationMode=Force (333,111 or 333.111)"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="4"
Margin="10,10,10,0">
<TextBox Name="NumberValidatorDynamic"
ui:TextBoxRegex.ValidationMode="Dynamic"
ui:TextBoxRegex.ValidationType="Number"
ui:TextBoxExtensions.ValidationMode="Dynamic"
ui:TextBoxExtensions.ValidationType="Number"
Header="Text box with ValidationType=Number, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
HeaderTemplate="{StaticResource HeaderTemplate}"
Style="{StaticResource TextBoxRegexStyle}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Is Valid: " />
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
</StackPanel>
</StackPanel>

Просмотреть файл

@ -60,7 +60,7 @@ namespace Microsoft.Toolkit.Uwp.UI
/// </summary>
/// <param name="obj">TextBox control</param>
/// <returns>placeholder value</returns>
public static string GetPlaceHolder(TextBox obj)
public static string GetMaskPlaceholderCharacter(TextBox obj)
{
return (string)obj.GetValue(MaskPlaceholderCharacterProperty);
}
@ -70,7 +70,7 @@ namespace Microsoft.Toolkit.Uwp.UI
/// </summary>
/// <param name="obj">TextBox Control</param>
/// <param name="value">placeholder Value</param>
public static void SetPlaceHolder(TextBox obj, string value)
public static void SetMaskPlaceholderCharacter(TextBox obj, string value)
{
obj.SetValue(MaskPlaceholderCharacterProperty, value);
}