Sunday, 25 August 2013

How to Bind Click Event to ViewModel when creating control in code

How to Bind Click Event to ViewModel when creating control in code

Typically, I create the View in xaml, and bind Events to the ViewModel
using Caliburn.Micro.
<Button cal:Message.Attach="[MouseLeftButtonUp]=[ModifyList($source)]" />
However, I now need to create the button in code, based on configuration
data.
The code is not in the CodeBehind, it's in a Factory class.
Button button = new Button(){Content = "Click Me"};
So the question is how to wire up the event?
Greg

No comments:

Post a Comment