If we try to data-bind the Password property of a PasswordBox control we end up with an error because the Password property cannot be bound due to the fact that is not a dependency property (mainly for security reasons).

In those cases you can take advantage of the PasswordBoxBehavior in the following manner:

<behaviors:PasswordBoxBehavior Text="{Binding Path=MyPasswordProperty}" />

where the behaviors xml namespace is defined as: In the same namespace is also defined a Password attached property that exposes exactly the same behavior.

The password behavior, and the attached property too, also exposes a Command property useful to bind a command to the “enter” key when the PasswordBox is focused.