基本上我在我的自定義類中有一個事件。我將使用事件的參數 - >屬性作爲該方法的參數調用自定義類中的特定方法。如何在交互中將事件參數作爲參數傳遞。使用MVVM時觸發?
您可以觀察此信息背後的實際代碼。
instance.FileOpening += (sender, e) =>
{
CustomClass.Method(e.XXproperty, e.YYproperty);
};
但是我想通過interactive.Triggers在MVVM中實現這一點。所以我在xaml中使用了下面的代碼。
<i:Interaction.Triggers>
<i:EventTrigger EventName="FileOpening">
<i:FileOpeningAction TargetObject="{Binding ElementName=cntrol}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
我的相應TargetedTriggerAction類在這裏讓我的自定義類執行該方法。
public class FileOpeningAction :TargetedTriggerAction<CustomClass>
{
protected override void Invoke(object parameter)
{
((instance).TargetObject).Method(?,?);
}
}
但我的問題是如何傳遞的e.XXproperty和e.YYproperty在上述行動中執行我的自定義類中的方法?
爲了增加這個答案: 的「EI」命名空間是「http://schemas.microsoft.com/expression/2010/interactions」,你需要一個參考Microsoft.Expression.Interactions – gbieging