Add multiple event handlers for one event in XAML?

Viewed 8143

in procedural code in can do the following:

// Add two event handler for the button click event
button1.Click += new RoutedEventHandler(button1_Click_1);
button1.Click += new RoutedEventHandler(button1_Click_2);

But how can I add multiple event handlers for the button's click event in XAML? Thanks for any hint!

2 Answers

You can specify multiple handlers in xaml like this :

   <Style  TargetType="{x:Type Button}">            
        <EventSetter Event="Click" Handler="ChangeBackground1"/>
        <EventSetter Event="Click" Handler="ChangeBackground2"/>
        <EventSetter Event="Click" Handler="ChangeBackground3"/>
        <EventSetter Event="Click" Handler="ChangeBackground4"/>
   </Style>
Related