TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
357
120.8k
PropertyChangedEventHandler and Delegates & Events in general
Mar 27 2012 12:41 PM
Hi
I would just like clarification on Delegates and Events in particular the PropertyChangedEventHandler delegate. I think ive got a good grasp but I just wanted to be put right in certain places if necessary please.
// Declare PropertyChangedEventArgs which derives from the EventArgs base. This is used as it contains additional functionality instead of using the standard EventArgs.
public class PropertyChangedEventArgs : Eventargs
public PropertyChangedEventArgs(string propertyName);
public virtual string PropertyName { get; }
// Declare Delegate which takes PropertyChangedEventArgs as the 2nd parameter due to the added functionality it provides (as in the step above).
public delegate void PropertyChangedEventHandler(object sender, PropertyChangedEventArgs e)
// Declare the EventHandler with an identifer\variable named PropertyChanged.
public event PropertyChangedEventHandler PropertyChanged
// Declare a method that fires the Event which matches the signiture of the delegate and holds a reference to the EventHandler.
public void RaisePropertyChanged(string propertyName)
PropertychangedEventHandler propertyChanged = PropertyChanged;
if(propertyChanged != null)
// Not sure
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
My question is how could this Event be assigned to a method I know it is subscribed by using the operator += and removed as a subscriber by -=
Thanks!
Reply
Answers (
4
)
WPF
Help making an array of timers