public AllSubjects() { InitializeComponent(); SubjectList.BindingContext = subjectViewModel; var sortTapGestureRecognizer = new TapGestureRecognizer(); sortTapGestureRecognizer.Tapped += (s, e) => { if (currentSort == 1) { currentSort = 2; //z-a SortIcon.Source = "azup.png"; subjectViewModel = new SubjectViewModel(subjectViewModel.SortZA()); SubjectList.BindingContext = subjectViewModel; } else if (currentSort == 2) { currentSort = 3; //5-0 SortIcon.Source = "stardown.png"; subjectViewModel = new SubjectViewModel(subjectViewModel.Sort50()); SubjectList.BindingContext = subjectViewModel; } else if (currentSort == 3) { currentSort = 4; //0-5 SortIcon.Source = "starup.png"; subjectViewModel = new SubjectViewModel(subjectViewModel.Sort05()); SubjectList.BindingContext = subjectViewModel; } else { currentSort = 1; //a-z SortIcon.Source = "azdown.png"; subjectViewModel = new SubjectViewModel(subjectViewModel.SortAZ()); SubjectList.BindingContext = subjectViewModel; } }; SortIcon.GestureRecognizers.Add(sortTapGestureRecognizer); }