0

Hoping this is an easy question that I'm just overlooking something...

I want to submit my logon form when a user hits enter from within a passwordbox. Is there a way to do this without capturing keystrokes & determine when enter is being hit?

Thx

Scott

Scott Silvi
  • 3,059
  • 5
  • 40
  • 63
  • 1
    By capturing keystrokes do you mean registering for KeyDown? Technically you can listen without actually capturing anything per se. Why is this a requirement? – bendewey Apr 26 '11 at 20:20
  • I know in WPF there's an isDefaulted property that you can set that auto-does this. [SO Post here](http://stackoverflow.com/questions/1179610/whats-the-best-way-to-catch-the-return-key-in-a-passwordbox-wpf-xaml) It's much less verbose then analyzing individual keys. – Scott Silvi Apr 26 '11 at 20:35

1 Answers1

1

Silverlight doesn't support AcceptButton property/behavior that WinForms has. You'll have to manage the KeyDown event, looking for an Enter key. There's nothing wrong with that, if you wanted the password you could just look at the text property in the text box. Your program has full access to the password, so shying away from a KeyDown event seems kind of frivolous. Monitoring the KeyDown event is a legitimate way to get things done in your code.

Seth Moore
  • 3,575
  • 2
  • 23
  • 33
  • Oh yeah I wasn't concerned about it from that standpoint. I know Mvvm doesn't prohibit view-level code, but it definitely makes me look for declarative ways of handling things (similar to isDefaulted that WPF uses, mentioned in my comment to my OP). I am simply trying to keep my view clean if possible. Doesn't look like there's a way to do that in SL yet. Thx – Scott Silvi Apr 26 '11 at 20:37