PasswordBox and MVVM

后端 未结 5 1570
再見小時候
再見小時候 2021-02-02 13:35

We have the following scenario:

  1. MVVM userinterface where a user can place his password (actually a PasswordBox)
  2. Server that shall do some wor
5条回答
  •  别跟我提以往
    2021-02-02 14:16

    IMO the solution proposed by DinoM above is the more elegant solution and much more understandable than the 'Passwordhelper' class utilised in both the links provide by Chandramouleswaran Ravichandra above (But all credit to Samuel Jack for coming up with it in his blog http://blog.functionalfun.net/2008/06/wpf-passwordbox-and-data-binding.html )

    To those who couldn't get DinoM's solution to work because of the missing 'UserCredentialsInputControl' type, just change this parameter to typeof(PasswordUserControl) and it will work.

    SingletonSean has a video on his Youtube channel entitled;

    Binding to a PasswordBox (MVVM) - EASY WPF (.NET CORE) ( https://www.youtube.com/watch?v=G9niOcc5ssw )

    This is the best source I have found in terms of being a complete example, except that he uses string instead of SecureString for the base type of the PasswordProperty but that's easily fixable. He also provides a link to the video's source code in his GitHub repo.

提交回复
热议问题