Caliburn.Micro support for PasswordBox?

前端 未结 3 462
遇见更好的自我
遇见更好的自我 2020-12-25 13:03

The Caliburn.Micro home page at http://caliburnmicro.com makes the below claim but I am unable to make CM work with a PasswordBox control using any variation I can think of

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-25 13:27

    The solutions provided here seem to be needlessly complicated.

    We can very easily use Caliburn.Micro actions to send our password to the ViewModel.

    XAML:

    
    

    ViewModel:

    public void OnPasswordChanged(PasswordBox source)
    {
        password = source.Password;
    }
    

    Then remember to clear the password fields so they don't remain in memory.

    NOTE: Obviously this solution doesn't allow you to easily change the password from the ViewModel, if that is necessary, then it's probably best to go with the attached property approach.

提交回复
热议问题