KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have come across a problem with binding to a PasswordBox . It seems it's a security risk but I am using the MVVM pattern so I wish to bypass this. I found some interesting code here (has anyone used this or something similar?) http://www.wpftutorial.net/PasswordBox.html It technically looks great, but I am unsure of how to retrieve the password. 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 private DelegateCommand loginCommand; public string Username { get; set; } public string Password { get; set; } public ICommand LoginCommand { get { if (loginCommand == null) { loginCommand = new DelegateCommand( Login, CanLogin ); } return loginCommand; } } private bool CanLogin() { return !str
Tags (comma-separated)
Save Edits
Cancel