CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2010
    Posts
    1

    invoking a button mouse click by pressing enter key in mvvm

    how can u invoke a button mouse click by pressing enter key in mvvm?
    I would like to submit a xaml form by pressing enter.
    I will describe the problem: Lets assume I have a fiel called: Name, the data in the field is binded to the Name property in the view model. the data is updated in the property only when the textbox looses focus.
    mouse click on the button makes the textbox loosing focus, but pressing enter cannot do that. so the result is the the data in the textbox is not updated in the property. therefore I cannot submit my form with pressing enter key, and I cannot use validation tools on my field as well because of this.
    what is the solution for this problem?

    thanks

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: invoking a button mouse click by pressing enter key in mvvm

    Quote Originally Posted by steve33 View Post
    what is the solution for this problem?
    Change the binding so the text changes when the user changes the text rather than after focus is lost. Wait to perform the validation until the user clicks on the button or presses enter.

    What binding on you currently using on the text box?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured