7
7
namespace MaterialDesignThemes . Wpf
8
8
{
9
9
/// <summary>
10
- /// The text field .
10
+ /// Helper properties for working with text fields .
11
11
/// </summary>
12
12
public static class TextFieldAssist
13
13
{
14
- #region Static Fields
15
-
16
14
/// <summary>
17
15
/// The hint property
18
16
/// </summary>
@@ -23,44 +21,14 @@ public static class TextFieldAssist
23
21
new FrameworkPropertyMetadata ( default ( string ) , FrameworkPropertyMetadataOptions . Inherits ) ) ;
24
22
25
23
/// <summary>
26
- /// The text box view margin property
27
- /// </summary>
28
- public static readonly DependencyProperty TextBoxViewMarginProperty = DependencyProperty . RegisterAttached (
29
- "TextBoxViewMargin" ,
30
- typeof ( Thickness ) ,
31
- typeof ( TextFieldAssist ) ,
32
- new PropertyMetadata ( new Thickness ( double . NegativeInfinity ) , TextBoxViewMarginPropertyChangedCallback ) ) ;
33
-
34
- /// <summary>
35
- /// The hint opacity property
36
- /// </summary>
37
- public static readonly DependencyProperty HintOpacityProperty = DependencyProperty . RegisterAttached (
38
- "HintOpacity" ,
39
- typeof ( double ) ,
40
- typeof ( TextFieldAssist ) ,
41
- new PropertyMetadata ( .48 ) ) ;
42
-
43
- /// <summary>
44
- /// Internal framework use only.
45
- /// </summary>
46
- public static readonly DependencyProperty TextProperty = DependencyProperty . RegisterAttached (
47
- "Text" , typeof ( string ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( default ( string ) , TextPropertyChangedCallback ) ) ;
48
-
49
- private static readonly DependencyPropertyKey IsNullOrEmptyPropertyKey = DependencyProperty . RegisterAttachedReadOnly (
50
- "IsNullOrEmpty" , typeof ( bool ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( true ) ) ;
51
-
52
- private static readonly DependencyProperty IsNullOrEmptyProperty =
53
- IsNullOrEmptyPropertyKey . DependencyProperty ;
54
-
55
- /// <summary>
56
- /// Framework use only.
24
+ /// Sets the hint.
57
25
/// </summary>
58
- public static readonly DependencyProperty ManagedProperty = DependencyProperty . RegisterAttached (
59
- "Managed" , typeof ( TextBox ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( default ( TextBox ) , ManagedPropertyChangedCallback ) ) ;
60
-
61
- #endregion
62
-
63
- #region Public Methods and Operators
26
+ /// <param name="element">The element.</param>
27
+ /// <param name="value">The value.</param>
28
+ public static void SetHint ( DependencyObject element , string value )
29
+ {
30
+ element . SetValue ( HintProperty , value ) ;
31
+ }
64
32
65
33
/// <summary>
66
34
/// Gets the hint.
@@ -74,6 +42,25 @@ public static string GetHint(DependencyObject element)
74
42
return ( string ) element . GetValue ( HintProperty ) ;
75
43
}
76
44
45
+ /// <summary>
46
+ /// The text box view margin property
47
+ /// </summary>
48
+ public static readonly DependencyProperty TextBoxViewMarginProperty = DependencyProperty . RegisterAttached (
49
+ "TextBoxViewMargin" ,
50
+ typeof ( Thickness ) ,
51
+ typeof ( TextFieldAssist ) ,
52
+ new PropertyMetadata ( new Thickness ( double . NegativeInfinity ) , TextBoxViewMarginPropertyChangedCallback ) ) ;
53
+
54
+ /// <summary>
55
+ /// Sets the text box view margin.
56
+ /// </summary>
57
+ /// <param name="element">The element.</param>
58
+ /// <param name="value">The value.</param>
59
+ public static void SetTextBoxViewMargin ( DependencyObject element , Thickness value )
60
+ {
61
+ element . SetValue ( TextBoxViewMarginProperty , value ) ;
62
+ }
63
+
77
64
/// <summary>
78
65
/// Gets the text box view margin.
79
66
/// </summary>
@@ -86,6 +73,15 @@ public static Thickness GetTextBoxViewMargin(DependencyObject element)
86
73
return ( Thickness ) element . GetValue ( TextBoxViewMarginProperty ) ;
87
74
}
88
75
76
+ /// <summary>
77
+ /// The hint opacity property
78
+ /// </summary>
79
+ public static readonly DependencyProperty HintOpacityProperty = DependencyProperty . RegisterAttached (
80
+ "HintOpacity" ,
81
+ typeof ( double ) ,
82
+ typeof ( TextFieldAssist ) ,
83
+ new PropertyMetadata ( .48 ) ) ;
84
+
89
85
/// <summary>
90
86
/// Gets the text box view margin.
91
87
/// </summary>
@@ -99,45 +95,60 @@ public static double GetHintOpacityProperty(DependencyObject element)
99
95
}
100
96
101
97
/// <summary>
102
- /// Sets the hint.
98
+ /// Sets the hint opacity .
103
99
/// </summary>
104
100
/// <param name="element">The element.</param>
105
101
/// <param name="value">The value.</param>
106
- public static void SetHint ( DependencyObject element , string value )
102
+ public static void SetHintOpacity ( DependencyObject element , double value )
107
103
{
108
- element . SetValue ( HintProperty , value ) ;
104
+ element . SetValue ( HintOpacityProperty , value ) ;
109
105
}
110
106
111
107
/// <summary>
112
- /// Sets the text box view margin .
108
+ /// Internal framework use only .
113
109
/// </summary>
114
- /// <param name="element">The element.</param>
115
- /// <param name="value">The value.</param>
116
- public static void SetTextBoxViewMargin ( DependencyObject element , Thickness value )
110
+ public static readonly DependencyProperty TextProperty = DependencyProperty . RegisterAttached (
111
+ "Text" , typeof ( string ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( default ( string ) , TextPropertyChangedCallback ) ) ;
112
+
113
+ /// <summary>
114
+ /// Internal framework use only.
115
+ /// </summary>
116
+ public static void SetText ( DependencyObject element , string value )
117
117
{
118
- element . SetValue ( TextBoxViewMarginProperty , value ) ;
118
+ element . SetValue ( TextProperty , value ) ;
119
119
}
120
120
121
121
/// <summary>
122
- /// Sets the hint opacity .
122
+ /// Internal framework use only .
123
123
/// </summary>
124
- /// <param name="element">The element.</param>
125
- /// <param name="value">The value.</param>
126
- public static void SetHintOpacity ( DependencyObject element , double value )
124
+ public static string GetText ( DependencyObject element )
127
125
{
128
- element . SetValue ( HintOpacityProperty , value ) ;
126
+ return ( string ) element . GetValue ( TextProperty ) ;
129
127
}
130
128
131
- public static void SetText ( DependencyObject element , string value )
129
+ private static readonly DependencyPropertyKey IsNullOrEmptyPropertyKey = DependencyProperty . RegisterAttachedReadOnly (
130
+ "IsNullOrEmpty" , typeof ( bool ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( true ) ) ;
131
+
132
+ private static readonly DependencyProperty IsNullOrEmptyProperty =
133
+ IsNullOrEmptyPropertyKey . DependencyProperty ;
134
+
135
+ private static void SetIsNullOrEmpty ( DependencyObject element , bool value )
132
136
{
133
- element . SetValue ( TextProperty , value ) ;
137
+ element . SetValue ( IsNullOrEmptyPropertyKey , value ) ;
134
138
}
135
139
136
- public static string GetText ( DependencyObject element )
140
+ public static bool GetIsNullOrEmpty ( DependencyObject element )
137
141
{
138
- return ( string ) element . GetValue ( TextProperty ) ;
142
+ return ( bool ) element . GetValue ( IsNullOrEmptyProperty ) ;
139
143
}
140
144
145
+ /// <summary>
146
+ /// Framework use only.
147
+ /// </summary>
148
+ public static readonly DependencyProperty ManagedProperty = DependencyProperty . RegisterAttached (
149
+ "Managed" , typeof ( TextBox ) , typeof ( TextFieldAssist ) , new PropertyMetadata ( default ( TextBox ) , ManagedPropertyChangedCallback ) ) ;
150
+
151
+
141
152
/// <summary>
142
153
/// Framework use only.
143
154
/// </summary>
@@ -156,7 +167,7 @@ public static TextBox GetManaged(DependencyObject element)
156
167
return ( TextBox ) element . GetValue ( ManagedProperty ) ;
157
168
}
158
169
159
- #endregion
170
+
160
171
161
172
#region Methods
162
173
@@ -261,16 +272,6 @@ private static void ManagedTextBoxOnIsVisibleChanged(object sender, DependencyPr
261
272
} ) ) ;
262
273
}
263
274
264
- private static void SetIsNullOrEmpty ( DependencyObject element , bool value )
265
- {
266
- element . SetValue ( IsNullOrEmptyPropertyKey , value ) ;
267
- }
268
-
269
- public static bool GetIsNullOrEmpty ( DependencyObject element )
270
- {
271
- return ( bool ) element . GetValue ( IsNullOrEmptyProperty ) ;
272
- }
273
-
274
275
#endregion
275
276
}
276
277
}
0 commit comments