Directory Freebies VS CheatSheet Forum

RSS

Email

Translate

Home About Archive Privacy Contact Advertise Write for Dev102

Hi

 

While working on a complex UI application in WPF I noticed that because I was using DataTemplates both the Xaml and the Code Behind got very messy, that is because if you need to implement some events in the code behind you basically “mix” code from the template and code from the Window, plus you cannot access the elements in the template from the code behind.

Let’s look at the following example:


Continue Reading...
Posted by Shahar Y on Sep 22nd, 2008 | Filed under .Net, C# | 7 Comments

Here is the code which defines a C# EventHandler, as written in the documentation, it represents the method that will handle an event that has no event data:

// Summary:
//     Represents the method that will handle an event that has no event data.
//
// Parameters:
//   sender:
//     The source of the event.
//
//   e:
//     An System.EventArgs that contains no event data.
[Serializable]
[ComVisible(true)]
public delegate void EventHandler(object sender, EventArgs e);

So after declaring a specific event:

private event EventHandler OnSomethingHappened;

We need to write a method to raise this event:


Continue Reading...
Posted by Amit on Mar 26th, 2008 | Filed under .Net, C# | 14 Comments

We all know the pattern to declare an event in C#, fairly easy, here is a remainder:
1: public class EventTest
2: {
3: public event EventHandler MyEvent;
[...]


Continue Reading...
Write Article for Dev102

Write for Dev102!

We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution

Learn More