Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WPF Login window with a username, password textbox & 7 textboxes for OTP since OTP is 7 digits long.
How to bind the ViewModel property "LoginOTP" to these 7 OTP textboxes on the Login View.

Should I create 7 different OTP properties in the ViewModel?

What I have tried:

I suggested changing the 7 textboxes to one but the client wants it to be 7 different textboxes to indicate the user to enter all 7 digits of the OTP
Posted
Updated 31-Jan-23 8:37am

1 solution

I would make a UserControl that would bind to a property on the ViewModel and internally split the string into the 7 parts, each bound to the 7 TextBoxes. To the ViewModel, it would appear to be a single binding, like a single TextBox. The validation can still be done via the ViewModel.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900