Question

I have more than one PasswordBox on my view and I want to pass all their SecureStrings to my view model when I click a button.

My guess is that I want to populate an instance of a custom class with all the SecureStrings and pass that object as a parameter to the RelayCommand bound to the button. If I only knew how...

My current idea for a work around:

In the RelayCommands action for the button: send out a NotificationMessageAction with a callback taking a custom class as parameter. Register for that message in the views code behind, and then populate an object with the SecureStrings, and then pass that object back to the view model with the help of the callback. Not very nice...

There must be a better way to do this in XAML, right?

Was it helpful?

Solution

Actually, I think what you want to do is implement event handlers, or an attached behavior on your PaswordBoxes that will push the SecureStrings to properties in the same viewmodel object that will be handling the RelayCommand's action. Then your RelayCommand won't need any parameters at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top