Skip to main content

PasswordBoxExtensions

C# API / Fluence.Wpf.Controls

  • Assembly: Fluence.Wpf
  • Namespace: Fluence.Wpf.Controls
public static class PasswordBoxExtensions

Provides attached properties that extend the sealed PasswordBox with the Fluent Design chrome this library ships: a placeholder, a rounded corner radius, a reveal (peek) button, a Caps Lock indicator, and a password strength meter.

Remarks: PasswordBox is sealed, so this library cannot subclass it the way it subclasses TextBox. Sealing blocks inheritance but not templating, so the library styles the native control instead. Everything that would otherwise be a dependency property on a derived type lives here as an attached property. The control a consumer places in their tree stays a real PasswordBox: one focus target, one automation element, the operating system secure store behind SecurePassword, and the native clipboard, IME, and context menu policy.

The implicit Fluent style sets IsFluentDecoratedProperty, which is what attaches the behavior. An application that wants the native behavior back can clear it.

C# source

Methods​

GetCornerRadius​

public static CornerRadius GetCornerRadius(this PasswordBox obj)

Gets the corner radius of the password box chrome.

Parameter obj: The password box to read from or write to.

Returns: The corner radius.

GetHasPassword​

public static bool GetHasPassword(this PasswordBox obj)

Gets whether the field currently holds a password. The Fluent template uses this to hide the placeholder and the reveal button, because the native Password is not a dependency property and so cannot be observed by a trigger.

Parameter obj: The password box to read from or write to.

Returns: true when the field holds a password; otherwise false.

GetIsFluentDecorated​

public static bool GetIsFluentDecorated(this PasswordBox obj)

Gets whether the Fluent password box behavior is attached to the specified element.

Parameter obj: The password box to read from or write to.

Returns: true when the behavior is attached; otherwise false.

GetIsPasswordRevealed​

public static bool GetIsPasswordRevealed(this PasswordBox obj)

Gets whether the password is currently revealed (peeked at).

Parameter obj: The password box to read from or write to.

Returns: true while the password is revealed; otherwise false.

GetPasswordStrength​

public static int GetPasswordStrength(this PasswordBox obj)

Gets the strength score from 0 (weakest) to 4 (strongest). The behavior recomputes it whenever the password changes; a caller may overwrite it to score the password itself.

Parameter obj: The password box to read from or write to.

Returns: The strength score.

GetPlaceholderText​

public static string GetPlaceholderText(this PasswordBox obj)

Gets the placeholder text shown while the field is empty.

Parameter obj: The password box to read from or write to.

Returns: The placeholder text.

GetRevealButtonEnabled​

public static bool GetRevealButtonEnabled(this PasswordBox obj)

Gets whether the reveal button is offered once the field holds a password.

Parameter obj: The password box to read from or write to.

Returns: true when the reveal button is enabled; otherwise false.

GetShowCapsLockIndicator​

public static bool GetShowCapsLockIndicator(this PasswordBox obj)

Gets whether the Caps Lock indicator is shown while Caps Lock is active. Opt in per box.

Parameter obj: The password box to read from or write to.

Returns: true when the indicator is enabled; otherwise false.

GetShowPasswordStrength​

public static bool GetShowPasswordStrength(this PasswordBox obj)

Gets whether the password strength meter is displayed. Opt in per box.

Parameter obj: The password box to read from or write to.

Returns: true when the meter is shown; otherwise false.

SetCornerRadius​

public static void SetCornerRadius(this PasswordBox obj, CornerRadius value)

Sets the corner radius of the password box chrome.

Parameter obj: The password box to read from or write to.

Parameter value: The corner radius to apply.

SetIsFluentDecorated​

public static void SetIsFluentDecorated(this PasswordBox obj, bool value)

Sets whether the Fluent password box behavior is attached to the specified element. The implicit Fluent style sets this to true; clearing it restores the native behavior.

Parameter obj: The password box to read from or write to.

Parameter value: true to attach the behavior; otherwise false.

SetPasswordStrength​

public static void SetPasswordStrength(this PasswordBox obj, int value)

Sets the strength score from 0 (weakest) to 4 (strongest).

Parameter obj: The password box to read from or write to.

Parameter value: The strength score to store.

SetPlaceholderText​

public static void SetPlaceholderText(this PasswordBox obj, string value)

Sets the placeholder text shown while the field is empty.

Parameter obj: The password box to read from or write to.

Parameter value: The placeholder text to store.

SetRevealButtonEnabled​

public static void SetRevealButtonEnabled(this PasswordBox obj, bool value)

Sets whether the reveal button is offered once the field holds a password.

Parameter obj: The password box to read from or write to.

Parameter value: true to enable the reveal button; otherwise false.

SetShowCapsLockIndicator​

public static void SetShowCapsLockIndicator(this PasswordBox obj, bool value)

Sets whether the Caps Lock indicator is shown while Caps Lock is active.

Parameter obj: The password box to read from or write to.

Parameter value: true to enable the indicator; otherwise false.

SetShowPasswordStrength​

public static void SetShowPasswordStrength(this PasswordBox obj, bool value)

Sets whether the password strength meter is displayed.

Parameter obj: The password box to read from or write to.

Parameter value: true to show the meter; otherwise false.

Dependency property identifiers​

Use these identifiers with WPF property APIs. The matching CLR properties appear above when the control exposes them.

CornerRadiusProperty​

public static readonly DependencyProperty CornerRadiusProperty

Identifies the CornerRadius attached property.

HasPasswordProperty​

public static readonly DependencyProperty HasPasswordProperty

Identifies the read-only HasPassword attached property.

IsFluentDecoratedProperty​

public static readonly DependencyProperty IsFluentDecoratedProperty

Identifies the IsFluentDecorated attached property.

IsPasswordRevealedProperty​

public static readonly DependencyProperty IsPasswordRevealedProperty

Identifies the read-only IsPasswordRevealed attached property.

PasswordStrengthProperty​

public static readonly DependencyProperty PasswordStrengthProperty

Identifies the PasswordStrength attached property.

PlaceholderTextProperty​

public static readonly DependencyProperty PlaceholderTextProperty

Identifies the PlaceholderText attached property.

RevealButtonEnabledProperty​

public static readonly DependencyProperty RevealButtonEnabledProperty

Identifies the RevealButtonEnabled attached property.

ShowCapsLockIndicatorProperty​

public static readonly DependencyProperty ShowCapsLockIndicatorProperty

Identifies the ShowCapsLockIndicator attached property.

ShowPasswordStrengthProperty​

public static readonly DependencyProperty ShowPasswordStrengthProperty

Identifies the ShowPasswordStrength attached property.