Beispiel #1
0
 private void AddDay(WeeksList week)
 {
     if (week.Days.Count is 7)
     {
         Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Error", "Only 7 Days in a Week.", "OK"); });
     }
     else
     {
         ExercisesOnDay exercisesOnDay = new ExercisesOnDay();
         week.Days.Add(new DaysInWeek {
             Day = week.Days.Count + 1, exercisesOnDays = new ObservableRangeCollection <ExercisesOnDay> {
                 exercisesOnDay
             }
         });
     }
 }
Beispiel #2
0
        private async Task Add()
        {
            await Task.Run(() =>
            {
                ExercisesOnDay exercisesOnDay             = new ExercisesOnDay();
                ObservableRangeCollection <DaysInWeek> ds = new ObservableRangeCollection <DaysInWeek>
                {
                    new DaysInWeek {
                        Day = 1, exercisesOnDays = new ObservableRangeCollection <ExercisesOnDay> {
                            exercisesOnDay
                        }
                    }
                };

                Device.BeginInvokeOnMainThread(() => { _weeksList.Add(new WeeksList {
                        Week = _weeksList.Count + 1, Days = ds
                    }); MessagingCenter.Send("Scroll", "ScrollTo", "AddWeek"); });
            });
        }