I got the below solution in XAML side to bind an event to command and it works just fine.
References
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Button Definition :
<Button>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter" >
<i:InvokeCommandAction Command="{Binding FooCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
Problem: Now I need to do the same thing in code behind for my object which is a FrameworkElementFactory but I can't figure it out , I thought maybe some one can help me.
here is where I stopped:
FrameworkElementFactory newLabel = new FrameworkElementFactory(typeof(Label));
newLabel.SetValue(Label.BackgroundProperty, Brushes.DarkMagenta);
var eventTrigger = new System.Windows.Interactivity.EventTrigger("MouseDown");
var invokeCommandAction = new System.Windows.Interactivity.InvokeCommandAction()
{
CommandName = "FooCommand",
CommandParameter = new Object()
};
any help please?
Thanks in advance , Farzad