private void BaseViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "BindingBodyExercises") { SelectTrainingExercisesViewModel viewModel = sender as SelectTrainingExercisesViewModel; if (viewModel != null) { TouchViewCell touchViewCell; BodyExerciseSection.Clear(); foreach (var bindingBodyExercise in viewModel.BindingBodyExercises) { touchViewCell = new TouchViewCell() { IsIndicatorVisible = false, BindingContext = bindingBodyExercise, ImageWidthRequest = 100, ImageHeightRequest = 100, Height = 100 }; touchViewCell.Tapped += BodyExerciseItemTapped; touchViewCell.SetBinding(TouchViewCell.IsCheckedVisibleProperty, (BindingBodyExercise source) => source.Selected); touchViewCell.SetBinding(TouchViewCell.ImageProperty, (BindingBodyExercise source) => source.Image); touchViewCell.SetBinding(TouchViewCell.ValueProperty, (BindingBodyExercise source) => source.Name); BodyExerciseSection.Add(touchViewCell); } } } }
public SelectTrainingExercisesPage(SelectTrainingExercisesViewModel baseViewModel) : base(baseViewModel) { InitializeComponent(); baseViewModel.PropertyChanged += BaseViewModel_PropertyChanged; }