Hi
Can Anyone tell me? How to perform Event Handling in SilverLight?
Thanks in Advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jiteendra SampathiraoPosted Aug 9, 2011, 1:47 AM
Priya LingePosted Aug 9, 2011, 12:23 AM
1. Silverlight events are essentially the same event concept as defined by
the common language runtime (CLR) and the .NET Framework.
Silverlight supports the concept of routed events
2.Silverlight events are CLR events, and therefore are events that
we can handle with managed code.
For objects that are UI and declared in XAML, event handler code must be defined in the partial
class that serves as the code-behind for a XAML page.
3.If we are using code to add event handlers to objects that
appear in the run-time UI, a common practice for Silverlight is to add such handlers in response to an object lifetime event or callback,
such as Loaded or OnApplyTemplate, so that the event handlers on the relevant object
are ready for user-initiated events at run time.
void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
{
textBlock1.MouseEnter += new MouseEventHandler(textBlocks_MouseEnter);
textBlock1.MouseLeave += new MouseEventHandler(textBlocks_MouseLeave);
}
4.
There are two event cases:
Input events
Non-input events.
Input Events: The browser that hosts the Silverlight plug-in handles initial
input stimulus for the input events. This is because Silverlight works within the plug-in architecture of the hosting browser.
From the browser, the event is sent to the Silverlight plug-in.
Non-input Events: They report a state change to a particular object,
for example, the state change events that report asynchronous download
state or progress of actions initiated by Web Client. Some non-input events
provide lifetime information of objects at a framework level.
For example the FrameworkElement.Loaded event
Please see below link.
http://msdn.microsoft.com/en-us/library/cc189018(v=vs.95).aspx
Thanks.