PasswordBox with MVVM

前端 未结 5 954
情深已故
情深已故 2020-12-16 11:59

Hi people stackoverflow. I\'m working with MVVM, I have ViewModel call UserViewModel with a Property Password. In the View have a control P

5条回答
  •  清歌不尽
    2020-12-16 12:20

    For security reasons the Password property is not a dependency property and therefore you can't bind to it. Unfortunately you'll need to perform the binding in the code behind the old fashioned way (register for OnPropertyChanged event and update the value through code...)


    I quick search brings me to this blog post which shows how to write an attached property to sidestep the issue. Whether this is worth doing or not though really depends on your aversion to code-behind.

提交回复
热议问题