Tuesday, September 4, 2012

Set a binding programmatically for InvokeCommandAction

Set a binding programmatically for InvokeCommandAction

I can't set programmatically this binding:

<i:Interaction.Triggers>     <i:EventTrigger EventName="MouseLeftButtonDown">         <i:InvokeCommandAction Command="{Binding Path=Document.MyDelegateCommandProperty}" />     </i:EventTrigger> </i:Interaction.Triggers> 

I tried with:

InvokeCommandAction ica = new InvokeCommandAction(); Binding actionCommandBinding = new Binding("Document.MyDelegateCommandProperty"); BindingOperations.SetBinding(ica, InvokeCommandAction.CommandProperty, actionCommandBinding); System.Windows.Interactivity.EventTrigger eventTrigger = new System.Windows.Interactivity.EventTrigger("MouseLeftButtonDown"); eventTrigger.Actions.Add(ica); eventTrigger.Attach(myUiElement); 

Anyone can help?

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog