我无法以编程方式设置此绑定:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<i:InvokeCommandAction Command="{Binding Path=Document.MyDelegateCommandProperty}" />
</i:EventTrigger>
</i:Interaction.Triggers>
我试过:
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);
任何人都可以帮忙吗?