Search code examples
c#wpfxamleventtrigger

Call a Method from EventTrigger


I have the following XAML-Code (for testing, so it is not a "nice"-Code):

<Style TargetType="{x:Type MenuItem}">
    <Style.Triggers>
        <EventTrigger RoutedEvent="Click">
            <EventTrigger.Actions>
                <BeginStoryboard>                                    
                    <Storyboard Storyboard.TargetProperty="Width" >
                        <DoubleAnimation From="70" To="100"></DoubleAnimation>
                    </Storyboard>
                </BeginStoryboard>
           </EventTrigger.Actions>
       </EventTrigger>                        
    </Style.Triggers>
</Style>

Now I want to call a Method in my C#-Project, when this trigger runs. The DoubleAnimation-Thing was just added to see, if the Trigger is activated on click. How do I call the Method?


Solution

  • The native triggers do not support that, if you use the ones from Blend's Interactivity there is a CallMethodAction you can use.