@@ -77,7 +77,7 @@ public PasswordBox()
77
77
/// <summary>
78
78
/// Gets or sets the actual password (not asterisks).
79
79
/// </summary>
80
- public string Password
80
+ public string ? Password
81
81
{
82
82
get => ( string ) GetValue ( PasswordProperty ) ;
83
83
set => SetValue ( PasswordProperty , value ) ;
@@ -102,7 +102,7 @@ public bool IsPasswordRevealed
102
102
}
103
103
104
104
/// <summary>
105
- /// Gets or sets whether the password reveal button is enabled.
105
+ /// Gets or sets a value indicating whether gets or sets whether the password reveal button is enabled.
106
106
/// </summary>
107
107
public bool RevealButtonEnabled
108
108
{
@@ -147,15 +147,15 @@ protected virtual void OnPasswordCharChanged()
147
147
return ;
148
148
}
149
149
150
- UpdateWithLock ( ( ) => SetCurrentValue ( TextProperty , new string ( PasswordChar , Password . Length ) ) ) ;
150
+ UpdateWithLock ( ( ) => SetCurrentValue ( TextProperty , new string ( PasswordChar , Password ? . Length ?? 0 ) ) ) ;
151
151
}
152
152
153
153
/// <summary>
154
154
/// Called when the <see cref="IsPasswordRevealed"/> property changes.
155
155
/// </summary>
156
156
protected virtual void OnIsPasswordRevealedChanged ( )
157
157
{
158
- UpdateWithLock ( ( ) => SetCurrentValue ( TextProperty , IsPasswordRevealed ? Password : new string ( PasswordChar , Password . Length ) ) ) ;
158
+ UpdateWithLock ( ( ) => SetCurrentValue ( TextProperty , IsPasswordRevealed ? Password : new string ( PasswordChar , Password ? . Length ?? 0 ) ) ) ;
159
159
}
160
160
161
161
/// <inheritdoc/>
@@ -231,7 +231,7 @@ private void HandleHiddenModeUpdate(bool isTriggeredByTextInput)
231
231
232
232
UpdateWithLock ( ( ) =>
233
233
{
234
- SetCurrentValue ( TextProperty , new string ( PasswordChar , newPassword . Length ) ) ;
234
+ SetCurrentValue ( TextProperty , new string ( PasswordChar , newPassword ? . Length ?? 0 ) ) ;
235
235
SetCurrentValue ( PasswordProperty , newPassword ) ;
236
236
CaretIndex = caretIndex ;
237
237
RaisePasswordChangedEvent ( ) ;
0 commit comments