Login when user press enter in passwordtextbox
-
hi friends.. Currently i am developing wpf application using mvvm pattern. I have one textbox in which user enters his username and another passwordbox in which he enters password. Now what i want, after entering password when user press enter then LoginCommand which is binded with LoginButton will be fire.. This thing will be done if i wrote keypress event on codebehind..but i am using mvvm pattern so how to handle this in viewmodel?? Thanks a lot..
-
hi friends.. Currently i am developing wpf application using mvvm pattern. I have one textbox in which user enters his username and another passwordbox in which he enters password. Now what i want, after entering password when user press enter then LoginCommand which is binded with LoginButton will be fire.. This thing will be done if i wrote keypress event on codebehind..but i am using mvvm pattern so how to handle this in viewmodel?? Thanks a lot..
First of all, you don't have to get completely hung up on the View having no code behind it, in MVVM - it's a convention, not a hard and fast rule. Secondly, you should set your login button to be the default button using IsDefault="true" in the button attributes; this will trigger the Command behind the button on an Enter press.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
First of all, you don't have to get completely hung up on the View having no code behind it, in MVVM - it's a convention, not a hard and fast rule. Secondly, you should set your login button to be the default button using IsDefault="true" in the button attributes; this will trigger the Command behind the button on an Enter press.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
You're welcome. :-D
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.