propnot – Code Snippet for Property with PropertyChanged event
Using Silverlight 2 data binding, If we want the UI to be notified and updated with changes in the model, we have to implement System.ComponentModel.INotifyPropertyChanged interface:
public interface INotifyPropertyChanged
{
event PropertyChangedEventHandler PropertyChanged;
}
A property that wants to notify the program that its values was changed should raise the PropertyChanged event and provide the name of the property. For example:
public class Person : INotifyPropertyChanged
{
private string name;
public string Name
{
get
{
return this.name;
}
set
{
this.name = value;
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(Name));
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
In case you like to code fast as I like, and you use code snippets to speed things up, you can use propnot – code snippet with PropertyChanged event implementation like the sample above.
To use the snippet:
- Download this zip file.
- Extract the propnot.snippet file to your custom code snippets directory (C:\Users\guyb\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets).
- Use it in Visual Studio!
Enjoy!
אירועים למפתחים בחודש יוני 2008
MSDN Pulse - העדכון החודשי שלך!
תהנו!
גליון יוני 2008 של MSDN Pulse נשלח הבוקר
הגליון השלישי של MSDN Pulse - העדכון החודשי למפתחים בישראל נשלח היום ומכיל את רשימת הדברים החמים שהיו בחודש האחרון, וכן את רשימת האירועים המתוכננים לחודש הקרוב. כנסו לגליון יוני 2008 של MSDN Pulse.
שלושת הגליונות הראשונים הם במסגרת פיילוט שאנחנו עושים כדי לוודא שהתכנים, המבנה והאיכות של הניוזלטר תואמים את הצרכים של המפתחים בישראל. אם יש לכם הערות, הצעות או כל משוב אחר, נשמח לשמוע עליהם.
לאחר תקופת הפיילוט של הניוזלטר, הוא ישלח מדי חודש רק למפתחים הרשומים. כדי לוודא שאתם לא מפספסים את מה שחם ומה שהולך להיות חם עוד יותר, הרשמו לקהילת המפתחים והרשמו לקבלת MSDN Pulse.
תהנו!