How to "click" a button?

Jul 7, 2010 at 10:30 PM
Hi, I'm new to Caliburn and have some newbie questions. 1) I have Username & Password text boxes, which are binded to corresponding Username & Password properties on ViewModel. So far so good. 2) I have ViewModel with Login() method and CanLogin property. Login method returns IEnumerable<IResult> which are properly executed when user click the Login button. 3) I have OnKeyDown event attached to Password text box, with the purpose to programmatically click Login button, when user presses ENTER key. Question, how to I click Login button from inside my View? I can get the ViewModel by typecasting DataContext, but I cannot execute Login() result with proper context information. How do I proceed?
Coordinator
Jul 7, 2010 at 11:30 PM
I would investigate using a custom Trigger to wire up the ActionMessage to execute on Enter inside the Password box. I bet someone has created a trigger for just this purpose in the Blend community.
Jul 8, 2010 at 1:51 PM

Found an easier way.

Subclassed Button, made:

public void PerformClick()

  OnClick();
}

Now I have to replace all automatically clickable buttons with the new one.