EventTrigger binds to an event from a DataContext

I am trying to execute something like this:

<DataTemplate.Triggers> <EventTrigger RoutedEvent="{Binding MyEvent}"> <BeginStoryboard Storyboard="{StaticResource MyAnimation}" /> </EventTrigger> </DataTemplate.Triggers> 

MyEvent is an event from my DataContext.

This does not work because RoutedEvent cannot be a Binding expression. Any idea how to do this? Actually I need some combination of EventTrigger and DataTrigger ...

Solution with Blend SDK:

 <Interactivity:Interaction.Triggers> <Interactivity:EventTrigger SourceObject="{Binding}" EventName="MyEvent"> <ei:ControlStoryboardAction ControlStoryboardOption="Play"> <ei:ControlStoryboardAction.Storyboard> <Storyboard> .... </Storyboard> </ei:ControlStoryboardAction.Storyboard> </ei:ControlStoryboardAction> </Interactivity:EventTrigger> </Interactivity:Interaction.Triggers> 
+4
source share
1 answer

Using EventTriggers from Interactivity ( Blend SDK ) can be triggered on any event on any object, the native ones work only for RoutedEvents which you usually use only for controls.

+4
source

Source: https://habr.com/ru/post/1390046/


All Articles