Telerik
Skip Navigation LinksHome / Products / Silverlight Controls / Resources / Routed Events Framework

Support for Routed Events

Description:
With the Windows Presentation Foundation a new type of events were introduced - the Routed Events. They have provided the developer with an entirely new approach to the eventing and the event handling.

Basically, Routed Events traverse the logical tree upwards or downwards, depending on their Routing Strategy – Bubble and Tunnel respectively.  Most Routed Events have a corresponding CLR event that wraps them and allows developers to use the Routed Event as a standard CLR one, as well as to add handlers to it in the XAML. Another interesting thing to know is that by WPF convention, all tunneling events are prefixed with Preview – e.g. PreviewExpand.

For more details, please check the following MSDN article: Routed Events Overview

Implementation:
Telerik RadControls for Silverlight implement Routed Events in the way they are in WPF. By default, the Silverlight platform does not allow you to create custom Routed Events. However, Telerik managed to implement custom Routed Events for RadControls for Silverlight. To overcome the limitation of the platform Telerik introduced EventManager, RoutedEvent and RoutingStrategy types in the controls. These same types are available with WPF by default. Telerik RadControls for Silverlight used an equal mechanism as the one present in WPF.  The functionality from the WPF is mirrored exactly the same, so the use in Silverlight is identical.

Almost all of the events in RadControls for Silverlight  are Routed Events. This gives you more freedom when you design your applications since you can write instance handlers as well as class handlers for our controls. For example, if you want to handle all RadMenuItem Click events you can write: 

EventManager.RegisterClassHandler(typeof(TheClassThatWillHandleRadMenuItemsClik), RadMenuItem.ClickEvent, new RoutedEventHandler(OnMenuClick), true)   

private void OnMenuClick(object sender, RoutedEventArgs e)  
{  
RadMenuItem menuItem = e.Source as RadMenuItem;  
}

For more details please refer to the Hristo Hristov’s blog.

Product Sheet
Support Resources

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.