First, we need to set the TargetObject property to viewmodel / DataContext, because the method that is being called is available in view mode:
...... <i:Interaction.Triggers> <i:EventTrigger EventName="IsVisibleChanged"> <ei:CallMethodAction MethodName="VisibleTrigger" TargetObject="{Binding}"/> </i:EventTrigger> </i:Interaction.Triggers> ......
Secondly, EventTrigger does not seem to work specifically with the IsVisibleChanged event. So the code snippet above works for another event, but not IsVisibleChanged. We can find a workaround in the answer to this SO question , using PropertyChangedTrigger to listen for the Visibility property, instead of listening for the IsVisibleChanged event:
<i:Interaction.Triggers> <ei:PropertyChangedTrigger Binding="{Binding Visibility, ElementName=MyControlName}"> <ei:CallMethodAction MethodName="VisibleTrigger" TargetObject="{Binding}"/> </ei:PropertyChangedTrigger> </i:Interaction.Triggers>
Third, CallMethodAction does not seem to provide a way to pass a parameter to a method. To be able to call a method with a parameter, it is better to use InvokeCommandAction instead of CallMethodAction, as suggested here , as well as suggested by @Rohit in your previous question .
source share