0

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?

H.B.
  • 166,899
  • 29
  • 327
  • 400
Hunv
  • 385
  • 7
  • 17

1 Answers1

1

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

H.B.
  • 166,899
  • 29
  • 327
  • 400
  • Hmm, okay. Do you know some other on-Board possibilities to do something like that? I have a Treeview, where the single Items will be added by a template because I want Icons in front of it. This works fine so far. But now I added a Contextmenu and want wo call a Method, that shows me a new window when clicking a menuitem or delete the right-clicked entry from the treeview. – Hunv May 20 '12 at 18:21
  • after searching with different keywords I found a way to realize what I want to do: You can use the CommandBindings to call a method from this MenuItems. Here is a link, that helped me: http://stackoverflow.com/questions/601393/custom-command-wpf – Hunv May 20 '12 at 19:26