INotifyPropertyChanged et ObservableCollection WPF

Droit maintenant, j'ai un calendrier qui affiche seulement un mois(ce mois je passe). Je suis en train de laisser l'utilisateur choisir de quel mois et de l'année à partir d'une zone de liste déroulante et avoir le calendrier de mise à jour. Je suis à la liaison à l'aide de observablecollection qui je suis une sorte de familier. Je n'ai aucune idée de comment INotifyPropertyChanged fonctionne bien. Je n'ai jamais utilisé avant. L'aide ou des conseils est grandement apprécié. C'est ce que j'ai à ce jour:

public class Schedule : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public void Update(int propertyName)
    {
        if (propertyName != null)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                 handler.Invoke(this, new PropertyChangedEventArgs(propertyName.ToString()));
        }
    }


   //public void UpdateCal(PropertyChangedEventArgs e)
   //{
    //   if (PropertyChanged != null)
    //       PropertyChanged(this, e);
  // } 
    public string MonthWeek { get; set; }
    public string Year { get; set; }
    public string Month { get; set; }
    public string day { get; set; }
    public string WeekOfYear { get; set; }
    public string dayofweek { get; set; }

   //public string month {
    //   get {return Month; }
    //   set
    //   {
     //      UpdateCal(new PropertyChangedEventArgs("month"));
      // }
   //}
    public int WeekNo { get; set; }
    public int WeekDay { get; set; }
    public DateTime Date { get; set; }
 }

---C'est une autre classe que les chiffres où à lieu chaque jour sur la grille----

           public SchedulePage(MainWindow parentForm)
{
InitializeComponent();
pick = Convert.ToInt32(comboMonth.SelectedItem) + 1;
_parentForm = parentForm;
//DateTime date = new DateTime(year, month, day);
var t = new List<Schedule>();
DateTime curr = DateTime.Now;
// comboMonth.Items.Add(curr.Month);
DateTime newcurr = new DateTime(2011, pick, 1);
//  pickdate = datePickercal.SelectedDate;
// DateTime newcurr = new DateTime(curr.Year, curr.Month, 1);
var cal = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar;
var ms = cal.GetWeekOfYear(new DateTime(newcurr.Year, newcurr.Month, 1), System.Globalization.CalendarWeekRule.FirstDay, System.DayOfWeek.Sunday);
for (var i = 1; newcurr.Month == pick; newcurr = newcurr.AddDays(1))
{
var sched = new Schedule();
var month_week = (newcurr.Day / 7) ;
sched.MonthWeek = newcurr.GetWeekOfMonth().ToString();
sched.Month = newcurr.Month.ToString();
sched.Year = newcurr.Year.ToString();
sched.day = newcurr.Day.ToString();
sched.WeekOfYear = cal.GetWeekOfYear(newcurr, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString();
sched.dayofweek = newcurr.DayOfWeek.ToString();
t.Add(sched);
_parentForm.bindings.schedule.Add(new Schedule { WeekNo = newcurr.GetWeekOfMonth()-1, WeekDay = (int)newcurr.DayOfWeek, day = newcurr.Day.ToString() });
}
lblDate.Content = (newcurr.Month -1) + "/" + newcurr.Year;
DataContext = _parentForm.Bindings;

---Et cette classe fait le observablecollections-----

           public partial class BindingCamper 
{  //This class assist in binding campers from listview to the textboxes on the camperspage
public ObservableCollection<Camper> Campers { get; set; }
public ObservableCollection<Staff> StaffMembers { get; set; }
public ObservableCollection<Schedule> schedule { get; set; }
public BindingCamper()
{
Campers = new ObservableCollection<Camper>();
StaffMembers = new ObservableCollection<Staff>();
schedule = new ObservableCollection<Schedule>();
}

OriginalL'auteur TMan | 2011-10-28