private async void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null || !(e.SelectedItem is IWordViewModel)) { return; } if (Pushing) { return; } try { Pushing = true; await WordsPageSemaphore.WaitAsync(); if (!Pushing) { return; } if (this.Model.Words.Count > 300) { var page = new WordPage((IWordViewModel)e.SelectedItem); await Navigation.PushAsync(page); } else { var page = WordsPage; try { await page.CanPushSemaphore.WaitAsync(); page.SelectedItem = (IWordViewModel)e.SelectedItem; if (page.Parent == null) { await Navigation.PushAsync(page); } } finally { page.CanPushSemaphore.Release(); } } } catch { } finally { WordsPageSemaphore.Release(); Pushing = false; } (sender as ListView).SelectedItem = null; }
public ProceedViewModel(WordPage p) { page = p; if (p.BindingContext != null && p.BindingContext is IWordViewModel) { model = p.BindingContext as IWordViewModel; model.PropertyChanged += (s, e) => this.OnPropertyChanged(nameof(Message)); } if (model != null) { model.PropertyChanged += (s, e) => { ProceedCommand?.OnCanExecuteChanged(); OnPropertyChanged(nameof(Message)); }; } }