#608 – Class Handlers Are Invoked Before Instance Handlers

If you have a class handler defined for a particular routed event, as well as one or more instance handlers on different elements, when the event fires, the class handler will be invoked before any instance handlers.

        public MainWindow()

            // Class handler--called when user clicks on ANY Button
                new RoutedEventHandler(HandleAllButtons));

        private void HandleAllButtons(object sender, RoutedEventArgs e)
            Button b = (Button)e.Source;
            Trace.WriteLine(string.Format("* (CLASS handler) You clicked on [{0}] button", b.Content));

        // Click handler for Eliot button
        private void btnEliot_Click(object sender, RoutedEventArgs e)
            Trace.WriteLine("* (INSTANCE handler) You clicked on Eliot button");

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #608 – Class Handlers Are Invoked Before Instance Handlers

  1. Pingback: Dew Drop – July 23, 2012 (#1,369) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: