.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> WPF >> Post New Question Subscribe to Interview Questions

What is a Routed event?

Posted By :Gowthammanju     Posted Date :July 31, 2011    Points :40   Category :WPF 
In WPF application it contains many elements. These elements exist in an element tree relationship with each other. A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.

You can also find related Interview Question to What is a Routed event?  below: 

the difference between a delegate and an event

  
the difference between a delegate and an event

Hi


Here is the difference between a delegate and an event.

Delegate:

public class VikramDel

{

public delegate void VikramExampleDelegate(int num1,string str1);

public VikramExampleDelegate VikramDeleageteCallback;

}

Event:

public class VikramEvent

{

public delegate void VikramExampleEvent(int num1,string str2);

public event VikramExampleEvent VikramEventCallback;

}

So syntax wise there is only one difference that we have to use the event keyword with the event.

So the question comes why do we have a keyword when the same work can be done without using it. But there is a reason for the existence of the keyword event. Lets take an example how would a client work with this class

VikramDel V = new VikramDel();

V.VikramDeleageteCallback +=new

VikramDel.VikramExampleDelegate (this.VikDelegate);

Here we are adding a new target to the invocation list of the delegate. The same code will work with the other class also without any problem

VikramEvent V = new VikramEvent();

V.VikramEventCallback + =new

VikramEvent.VikramExampleEvent(this.VikDelegate);

But consider a case where by instead of adding a new target to the invocation list of the delegate if I simply set a delegate to a new delegate (The difference is with the + sign being not there).

VikramDel V = new VikramDel();

V.VikramDeleageteCallback =new

VikramDel.VikramExampleDelegate (this.VikDelegate);

This code will work fine here but the same will not work with an event.

So what it means is that if we use the event keyword no client class can set it to null. This is very important. Multiple clients can use the same delegate. After multiple client have added a function to listen to the callback of the delegate. But now one of the client sets the delegate to null or uses the = sign to add a new call back. This means that the previous invocation list will not be used any more. Hence all the previous client will not get any of the callback even if they have registered for the call back.

Hence we can say that the even keyword adds a layer of protection on the instance of the delegate. The protection prevents any client to reset the delegate invocation list. They can only add or remove the target from the invocation list. (More...)

What's a Bubbled Event ?

  
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents (More...)

How do I detach an event handler?

  
In the same way you attach an event handler, except using the -= operator.
For example:

button1.Click -= new EventHandler (button1_Click); (More...)

What is Event Bubbling?(Asp.net)

  
Server Controls like DataGrid,DataGridView , DataList etc have other controls inside them.
Example an DataGridView can have an TextBox or an button inside it.
These Child Controls can not raize events by themselves,but they pass the event to the parent control (DataGridView), which is passed to the page as "ItemCommand" event.
This process is known as EventBubling?

====================================================================
Regards Hefin Dsouza. (More...)

Which is the first event in page life-cycle Event?

  
Page_PreInit is the First event that will be executed on the page. (More...)

Where do you add an event handler?

  
Add an OnMouseOver attribute to the button. Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();"); (More...)

List the event handlers that can be included in Global.asax?

  
o Application start and end event handlers
o Session start and end event handlers
o Per-request event handlers
o Non-deterministic event handlers (More...)

What is the difference between Page_init and Page_Load event?

  
Page_init - This is the first event to occur in the lifecycle of ASP.NET. This event fires only the first time the page is loaded and from the next time on a postback Page_init is not fired.

Page_Load - This is the event where most of our work will be done, this event occurs
when all objects/controls on the page are created and will be available for use. (More...)

Suppose you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler?

  
Add an OnMouseOver attribute to the button. Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();"); (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend