public DoctorAppointmentsPage() { InitializeComponent(); _patientService = new PatientService(); _appoitmentService = new AppointmentService(); List<Appointment> list = _appoitmentService.FindAll();//GetNextAppointmentsByDoctorId(SessionData.UserSessionData.CurrentUserId); Dictionary<int, Patient> patientList = GetDictionary(_patientService.FindAll()); List<object> dataSet = null; if (list != null) { dataSet = new List<object>(); foreach (Appointment app in list) { Patient p = patientList[app.IdPacient]; dataSet.Add(new { AppointmentId = app.Id, Patient = p.FirstName + " " + p.LastName, Date = app.ScheduledDate.ToString(), Time = app.Time.ToString(), Symtoms = app.Symptoms.ToString() }); } this._cview = new PagingCollectionView(dataSet, 20); this.DataContext = this._cview; } else { buttonPrevious.IsEnabled = false; buttonNext.IsEnabled = false; } }