Password
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:
1
<PasswordBox>
2
<i:Interaction.Behaviors>
3
<behaviors:PasswordBoxBehavior Text="{Binding Path=MyPasswordProperty}" />
4
</i:Interaction.Behaviors>
5
</PasswordBox>
Copied!
where the behaviors xml namespace is defined as: http://schemas.radicalframework.com/windows/behaviors. 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.
Copy link