4
4
5
5
using System . Collections . Generic ;
6
6
using Windows . UI . Xaml ;
7
+ using Windows . UI . Xaml . Controls ;
7
8
8
9
namespace Microsoft . Toolkit . Uwp . UI
9
10
{
10
- /// <summary>
11
- /// TextBox mask property allows a user to more easily enter fixed width text in TextBox control
12
- /// where you would like them to enter the data in a certain format
13
- /// </summary>
14
- public partial class TextBoxMask
11
+ /// <inheritdoc cref="TextBoxExtensions"/>
12
+ public static partial class TextBoxExtensions
15
13
{
16
14
/// <summary>
17
15
/// Represents a mask/format for the textbox that the user must follow
18
16
/// </summary>
19
- public static readonly DependencyProperty MaskProperty = DependencyProperty . RegisterAttached ( "Mask" , typeof ( string ) , typeof ( TextBoxMask ) , new PropertyMetadata ( null , InitTextBoxMask ) ) ;
17
+ public static readonly DependencyProperty MaskProperty = DependencyProperty . RegisterAttached ( "Mask" , typeof ( string ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( null , InitTextBoxMask ) ) ;
20
18
21
19
/// <summary>
22
20
/// Represents the mask place holder which represents the variable character that the user can edit in the textbox
23
21
/// </summary>
24
- public static readonly DependencyProperty PlaceHolderProperty = DependencyProperty . RegisterAttached ( "PlaceHolder" , typeof ( string ) , typeof ( TextBoxMask ) , new PropertyMetadata ( DefaultPlaceHolder , InitTextBoxMask ) ) ;
22
+ public static readonly DependencyProperty PlaceHolderProperty = DependencyProperty . RegisterAttached ( "PlaceHolder" , typeof ( string ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( DefaultPlaceHolder , InitTextBoxMask ) ) ;
25
23
26
24
/// <summary>
27
25
/// Represents the custom mask that the user can create to add his own variable characters based on regex expression
28
26
/// </summary>
29
- public static readonly DependencyProperty CustomMaskProperty = DependencyProperty . RegisterAttached ( "CustomMask" , typeof ( string ) , typeof ( TextBoxMask ) , new PropertyMetadata ( null , InitTextBoxMask ) ) ;
27
+ public static readonly DependencyProperty CustomMaskProperty = DependencyProperty . RegisterAttached ( "CustomMask" , typeof ( string ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( null , InitTextBoxMask ) ) ;
30
28
31
- private static readonly DependencyProperty RepresentationDictionaryProperty = DependencyProperty . RegisterAttached ( "RepresentationDictionary" , typeof ( Dictionary < char , string > ) , typeof ( TextBoxMask ) , new PropertyMetadata ( null ) ) ;
32
- private static readonly DependencyProperty OldTextProperty = DependencyProperty . RegisterAttached ( "OldText" , typeof ( string ) , typeof ( TextBoxMask ) , new PropertyMetadata ( null ) ) ;
33
- private static readonly DependencyProperty DefaultDisplayTextProperty = DependencyProperty . RegisterAttached ( "DefaultDisplayText" , typeof ( string ) , typeof ( TextBoxMask ) , new PropertyMetadata ( null ) ) ;
34
- private static readonly DependencyProperty OldSelectionLengthProperty = DependencyProperty . RegisterAttached ( "OldSelectionLength" , typeof ( int ) , typeof ( TextBoxMask ) , new PropertyMetadata ( 0 ) ) ;
35
- private static readonly DependencyProperty OldSelectionStartProperty = DependencyProperty . RegisterAttached ( "OldSelectionStart" , typeof ( int ) , typeof ( TextBoxMask ) , new PropertyMetadata ( 0 ) ) ;
29
+ private static readonly DependencyProperty RepresentationDictionaryProperty = DependencyProperty . RegisterAttached ( "RepresentationDictionary" , typeof ( Dictionary < char , string > ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( null ) ) ;
30
+ private static readonly DependencyProperty OldTextProperty = DependencyProperty . RegisterAttached ( "OldText" , typeof ( string ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( null ) ) ;
31
+ private static readonly DependencyProperty DefaultDisplayTextProperty = DependencyProperty . RegisterAttached ( "DefaultDisplayText" , typeof ( string ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( null ) ) ;
32
+ private static readonly DependencyProperty OldSelectionLengthProperty = DependencyProperty . RegisterAttached ( "OldSelectionLength" , typeof ( int ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( 0 ) ) ;
33
+ private static readonly DependencyProperty OldSelectionStartProperty = DependencyProperty . RegisterAttached ( "OldSelectionStart" , typeof ( int ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( 0 ) ) ;
36
34
37
- private static readonly DependencyProperty EscapedMaskProperty = DependencyProperty . RegisterAttached ( "EscapedMask" , typeof ( string ) , typeof ( TextBoxMask ) , new PropertyMetadata ( null ) ) ;
38
- private static readonly DependencyProperty EscapedCharacterIndicesProperty = DependencyProperty . RegisterAttached ( "MaskEscapedCharacters" , typeof ( List < int > ) , typeof ( TextBoxMask ) , new PropertyMetadata ( null ) ) ;
35
+ private static readonly DependencyProperty EscapedMaskProperty = DependencyProperty . RegisterAttached ( "EscapedMask" , typeof ( string ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( null ) ) ;
36
+ private static readonly DependencyProperty EscapedCharacterIndicesProperty = DependencyProperty . RegisterAttached ( "MaskEscapedCharacters" , typeof ( List < int > ) , typeof ( TextBoxExtensions ) , new PropertyMetadata ( null ) ) ;
39
37
40
38
/// <summary>
41
39
/// Gets mask value
42
40
/// </summary>
43
41
/// <param name="obj">TextBox control</param>
44
42
/// <returns>mask value</returns>
45
- public static string GetMask ( DependencyObject obj )
43
+ public static string GetMask ( TextBox obj )
46
44
{
47
45
return ( string ) obj . GetValue ( MaskProperty ) ;
48
46
}
@@ -52,7 +50,7 @@ public static string GetMask(DependencyObject obj)
52
50
/// </summary>
53
51
/// <param name="obj">TextBox Control</param>
54
52
/// <param name="value">Mask Value</param>
55
- public static void SetMask ( DependencyObject obj , string value )
53
+ public static void SetMask ( TextBox obj , string value )
56
54
{
57
55
obj . SetValue ( MaskProperty , value ) ;
58
56
}
@@ -62,7 +60,7 @@ public static void SetMask(DependencyObject obj, string value)
62
60
/// </summary>
63
61
/// <param name="obj">TextBox control</param>
64
62
/// <returns>placeholder value</returns>
65
- public static string GetPlaceHolder ( DependencyObject obj )
63
+ public static string GetPlaceHolder ( TextBox obj )
66
64
{
67
65
return ( string ) obj . GetValue ( PlaceHolderProperty ) ;
68
66
}
@@ -72,7 +70,7 @@ public static string GetPlaceHolder(DependencyObject obj)
72
70
/// </summary>
73
71
/// <param name="obj">TextBox Control</param>
74
72
/// <param name="value">placeholder Value</param>
75
- public static void SetPlaceHolder ( DependencyObject obj , string value )
73
+ public static void SetPlaceHolder ( TextBox obj , string value )
76
74
{
77
75
obj . SetValue ( PlaceHolderProperty , value ) ;
78
76
}
@@ -82,7 +80,7 @@ public static void SetPlaceHolder(DependencyObject obj, string value)
82
80
/// </summary>
83
81
/// <param name="obj">TextBox control</param>
84
82
/// <returns>CustomMask value</returns>
85
- public static string GetCustomMask ( DependencyObject obj )
83
+ public static string GetCustomMask ( TextBox obj )
86
84
{
87
85
return ( string ) obj . GetValue ( CustomMaskProperty ) ;
88
86
}
@@ -92,7 +90,7 @@ public static string GetCustomMask(DependencyObject obj)
92
90
/// </summary>
93
91
/// <param name="obj">TextBox Control</param>
94
92
/// <param name="value">CustomMask Value</param>
95
- public static void SetCustomMask ( DependencyObject obj , string value )
93
+ public static void SetCustomMask ( TextBox obj , string value )
96
94
{
97
95
obj . SetValue ( CustomMaskProperty , value ) ;
98
96
}
0 commit comments