private void CitasCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (Cita cita in e.NewItems) { Cita cita1 = cita; this.Dispatcher.BeginInvoke( DispatcherPriority.Render, new Action(() => { var vistaCita = new CitaView { Cita = cita1, OnClickMe = new DelegateCommand <Cita>(ExecuteMethod) }; this.CitasRoot.Children.Add(vistaCita); this.Container.ScrollToVerticalOffset(this.Container.ActualHeight / 2); })); } Debug.WriteLine("Cita : Add"); break; case NotifyCollectionChangedAction.Remove: Debug.WriteLine("Cita : Remove"); break; case NotifyCollectionChangedAction.Replace: Debug.WriteLine("Cita : Replace"); break; case NotifyCollectionChangedAction.Move: Debug.WriteLine("Cita : Move"); break; case NotifyCollectionChangedAction.Reset: Debug.WriteLine("Cita : Reset"); this.CitasRoot.Children.Clear(); this.citasDibujadas.Clear(); break; default: throw new ArgumentOutOfRangeException(); } }
private void Redraw() { this.CitasRoot.Children.Clear(); foreach (Cita cita in this.Citas) { Cita cita1 = cita; this.Dispatcher.BeginInvoke( new Action(() => { var vistaCita = new CitaView { Cita = cita1, OnClickMe = new DelegateCommand <Cita>(ExecuteMethod) }; this.CitasRoot.Children.Add(vistaCita); })); } this.Container.ScrollToVerticalOffset(this.Container.ActualHeight / 2); }