![]() ![]() public SecureString SecurePassword you’ve got up there. Note that it is a SecureString, not just a string. I made it “write only” since there shouldn’t be a need to retrieve it from outside the ViewModel for any reason, but it doesn’t have to be. In the ViewModel, just a simple property. In this case, we are just manually coding a binding, so its all considered part of the UI implementation and therefore is ok. The ViewModel still has no knowledge of the View implementation, which in my mind it does if you are trying to pass the PasswordBox in to the ViewModel.Ĭode Behind != Automatic MVVM violation. ![]() #Xaml passwordbox binding codeYes, technically it is code behind, but it is nothing more than a “special case” binding. This method does not violate the MVVM pattern and maintains complete security. Maybe I am missing something, but it seems like most of these solutions overcomplicate things and do away with secure practices. 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 īool result = securityService.IsValidLogin(Username, Password) You can see I check my property for Username here which works great. When I press it CanLogin is called and if it returns true it calls Login. My code is very simple, basically I have a Command for my Button. When I had the PasswordBox as a TextBox and Binding Path=Password then the property in my LoginViewModel was updated. I used the code above as stated and entered this ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |