70 likes | 170 Vues
Routed Events. Mahender Senior Software Engineer United Health Group. Mahender Sarangam.
E N D
Routed Events Mahender Senior Software Engineer United Health Group
Mahender Sarangam • Having 5 years of experience on .NET Technologies. Working as a Senior Software Engineer in United Health Group (UHG India Information Service Ltd.). Worked with Big Firms like Deloitte Consulting & Wipro Technology. • Got Technical Acquaintance on Technologies like C#, ASP.NET,AJAX, LINQ, Silverlight, WPF,WCF ,SQL Server, Team Foundation Server(TFS) and SharePoint Technology. • MCTS Certified in Web Technologies. • Blog : http://Msarangam.wordpress.com
What are Routed Events? • Events in Silverlight are used much like events in any other .NET technology. • In Silverlight, there are two general event cases: input events and non-input events • For example, event routing allows a click that begins in a shape to rise up to that shape’s container and then to the containing page before it’s handled by your code. • There are three types of RoutedEvents - direct, tunneling, and bubbling
Direct - This type of routed events can be handled only by the controls that had raised them. They are very similar to the events we are familiar with from WinForms and ASP.NET. Tunneling - By this type of events, first the handlers of the root element of the visual tree are invoked and then the event travels through the child elements till it reaches the one that originally has raised it. Bubbling - This type of events is first handled by their source and then the event handlers of the parent elements are invoked till the event reaches the root element of the visual tree.
The main difference between routed events and standard CLR events, to the handler of the event, is that the event sender isn’t necessarily the original source of the event. • In order to get the original source of the event, you need to check the OriginalSource property of the RoutedEventArgs supplied to the handler.
Disadvantages in Routed in SL • There are some differences between the routed events in Silverlight and WPF. Here are the most important of them: • You cannot create custom RoutedEvents in Silverlight. In WPF to create a custom event of this type we use EventManager, but in Silverlight it's not available. • The only type of routed events in Silverlight is the bubbling event. Such events for example are the MouseLeftButtonDown and the MouseLeftButtonUp. • The control specific events don't bubble - for example the Click event of the Button control.