A problem with binding to a PasswordBox, it's a security risk but I am using the MVVM pattern I found some interesting code here
http://www.wpftutorial.net/PasswordBox.html
I basically have properties in my LoginViewModel for Username and Password. Username is fine and is working as it's a TextBox.
I used the code above as stated and entered this
<PasswordBox ff:PasswordHelper.Attach="True"
ff:PasswordHelper.Password="{Binding Path=Password}" Width="130"/>
When I had the PasswordBox as a TextBox and Binding Path=Password then the property in my LoginViewModel was updated.
My code is very simple, basically I have a Command for my Button. When I press it CanLogin is called and if it returns true it calls Login. You can see I check my property for Username here which works great.
In Login I send along to my service a Username and Password, Username contains data from my View but Password is Null|Empty
<TextBox Text="{Binding Path=Username, UpdateSourceTrigger=PropertyChanged}"
MinWidth="180" />
<PasswordBox ff:PasswordHelper.Attach="True"
ff:PasswordHelper.Password="{Binding Path=Password}" Width="130"/>
I have my TextBox, this is no problem, but in my ViewModel the Password is empty.
I put a breakpoint and sure enough the code enter the static helper class but it never updates my Password in my ViewModel