77namespace MaterialDesignThemes . Wpf
88{
99 /// <summary>
10- /// The text field .
10+ /// Helper properties for working with text fields .
1111 /// </summary>
1212 public static class TextFieldAssist
1313 {
14- #region Static Fields
15-
1614 /// <summary>
1715 /// The hint property
1816 /// </summary>
@@ -23,44 +21,14 @@ public static class TextFieldAssist
2321 new FrameworkPropertyMetadata ( default ( string ) , FrameworkPropertyMetadataOptions . Inherits ) ) ;
2422
2523 /// <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.
5725 /// </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+ }
6432
6533 /// <summary>
6634 /// Gets the hint.
@@ -74,6 +42,25 @@ public static string GetHint(DependencyObject element)
7442 return ( string ) element . GetValue ( HintProperty ) ;
7543 }
7644
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+
7764 /// <summary>
7865 /// Gets the text box view margin.
7966 /// </summary>
@@ -86,6 +73,15 @@ public static Thickness GetTextBoxViewMargin(DependencyObject element)
8673 return ( Thickness ) element . GetValue ( TextBoxViewMarginProperty ) ;
8774 }
8875
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+
8985 /// <summary>
9086 /// Gets the text box view margin.
9187 /// </summary>
@@ -99,45 +95,60 @@ public static double GetHintOpacityProperty(DependencyObject element)
9995 }
10096
10197 /// <summary>
102- /// Sets the hint.
98+ /// Sets the hint opacity .
10399 /// </summary>
104100 /// <param name="element">The element.</param>
105101 /// <param name="value">The value.</param>
106- public static void SetHint ( DependencyObject element , string value )
102+ public static void SetHintOpacity ( DependencyObject element , double value )
107103 {
108- element . SetValue ( HintProperty , value ) ;
104+ element . SetValue ( HintOpacityProperty , value ) ;
109105 }
110106
111107 /// <summary>
112- /// Sets the text box view margin .
108+ /// Internal framework use only .
113109 /// </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 )
117117 {
118- element . SetValue ( TextBoxViewMarginProperty , value ) ;
118+ element . SetValue ( TextProperty , value ) ;
119119 }
120120
121121 /// <summary>
122- /// Sets the hint opacity .
122+ /// Internal framework use only .
123123 /// </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 )
127125 {
128- element . SetValue ( HintOpacityProperty , value ) ;
126+ return ( string ) element . GetValue ( TextProperty ) ;
129127 }
130128
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 )
132136 {
133- element . SetValue ( TextProperty , value ) ;
137+ element . SetValue ( IsNullOrEmptyPropertyKey , value ) ;
134138 }
135139
136- public static string GetText ( DependencyObject element )
140+ public static bool GetIsNullOrEmpty ( DependencyObject element )
137141 {
138- return ( string ) element . GetValue ( TextProperty ) ;
142+ return ( bool ) element . GetValue ( IsNullOrEmptyProperty ) ;
139143 }
140144
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+
141152 /// <summary>
142153 /// Framework use only.
143154 /// </summary>
@@ -156,7 +167,7 @@ public static TextBox GetManaged(DependencyObject element)
156167 return ( TextBox ) element . GetValue ( ManagedProperty ) ;
157168 }
158169
159- #endregion
170+
160171
161172 #region Methods
162173
@@ -261,16 +272,6 @@ private static void ManagedTextBoxOnIsVisibleChanged(object sender, DependencyPr
261272 } ) ) ;
262273 }
263274
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-
274275 #endregion
275276 }
276277}
0 commit comments