我遇到了绑定到PasswordBox的问题.这似乎是一个安全风险,但我正在使用MVVM模式,所以我希望绕过这个.我在这里找到了一些有趣的代码(有没有人用过这个或类似的东西?)
http://www.wpftutorial.net/PasswordBox.html
它在技术上看起来很棒,但我不确定如何检索密码.
我基本上有我的LoginViewModelfor Username和属性Password.Username很好,正在工作,因为它是一个TextBox.
我按照说明使用了上面的代码并输入了这个
<PasswordBox ff:PasswordHelper.Attach="True"
ff:PasswordHelper.Password="{Binding Path=Password}" Width="130"/>
Run Code Online (Sandbox Code Playgroud)
当我有了PasswordBoxa TextBox,Binding Path=Password然后我的房产LoginViewModel被更新了.
我的代码很简单,基本上我有一个Commandfor my Button.当我按下它时会CanLogin被调用,如果它返回true,则调用它Login.
你可以看到我检查我的房产在Username这里工作得很好.
在Login我一起发送到我的服务Username和Password,Username包含数据从我View却Password是Null|Empty
private DelegateCommand loginCommand;
public string Username { get; set; }
public string Password { get; set; }
public ICommand LoginCommand
{
get
{ …Run Code Online (Sandbox Code Playgroud)