How to bind to a PasswordBox in MVVM

前端 未结 30 2367
执念已碎
执念已碎 2020-11-22 11:50

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 som

30条回答
  •  我在风中等你
    2020-11-22 12:17

    As you can see i am binding to Password, but maybe its bind it to the static class..

    It is an attached property. This kind of property can be applied to any kind of DependencyObject, not just the type in which it is declared. So even though it is declared in the PasswordHelper static class, it is applied to the PasswordBox on which you use it.

    To use this attached property, you just need to bind it to the Password property in your ViewModel :

    
    

提交回复
热议问题