Recommended

Skip Navigation LinksHome / Tips / View Tip

Tip: How to get reference to the object that raised a routed event?

+ Add to SilverlightShow Favorites
0 comments   /   posted by Denislav Savkov on Sep 17, 2008
(0 votes)
Categories: General

The callback function of a routed event has the second parameter e of type RoutedEventArgs or its inheritor. The Source property of this parameter holds reference to the object that raised the event. In contrast to that the sender parameter holds reference to the object where the event handler was invoked.

C#

void RoutedEventRaised( object sender, RoutedEventArgs e )
{
    object source = e.Source;
}

That's it!

Share


Comments

Comments RSS RSS
No comments

Add Comment

 
 

   
  
  
   
Please add 3 and 3 and type the answer here:

Join the free SilverlightShow webinar 'Silverlight Behaviors for Designers' on July 14th 2010, 3:00pm EDT.
In this session on adding interactivity UX Designer and Consultant Zhivko Dimitrov will show how to bring your designs to life without writing a single line of code! Find out how to use drag & drop behaviors to control animations, add navigation, and simulate validation states. Read more | Register Now (hide this)