public override void ViewDidLoad() { base.ViewDidLoad(); this.WhenAnyValue(x => x.ViewModel.Items) .Select(x => { var source = new LanguageTableViewSource(TableView, x); source.ElementSelected.OfType <LanguageItemViewModel>().Subscribe(y => ViewModel.SelectedLanguage = y); return(source); }).BindTo(TableView, x => x.Source); ViewModel.LoadCommand.IsExecuting.Where(x => !x).Take(1).SubscribeSafe(_ => { var selectedLanguageSlug = ViewModel.SelectedLanguage.Slug; var selectedLanguage = ViewModel.Items.Select((value, index) => new { value, index }) .Where(x => x.value.Slug == selectedLanguageSlug) .Select(x => x.index + 1) .FirstOrDefault() - 1; if (selectedLanguage >= 0) { var indexPath = NSIndexPath.FromRowSection(selectedLanguage, 0); BeginInvokeOnMainThread(() => TableView.ScrollToRow(indexPath, UIKit.UITableViewScrollPosition.Middle, true)); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var source = new LanguageTableViewSource(TableView, ViewModel.Languages); source.ElementSelected.OfType <LanguageItemViewModel>().Subscribe(x => ViewModel.SelectedLanguage = x); TableView.Source = source; // Loading is assumed to already have begun ViewModel.LoadCommand.IsExecuting.Where(x => !x).Take(1).SubscribeSafe(_ => { var selectedLanguageSlug = ViewModel.SelectedLanguage.Slug; var selectedLanguage = ViewModel.Languages.Select((value, index) => new { value, index }) .Where(x => x.value.Slug == selectedLanguageSlug) .Select(x => x.index + 1) .FirstOrDefault() - 1; if (selectedLanguage >= 0) { var indexPath = NSIndexPath.FromRowSection(selectedLanguage, 0); BeginInvokeOnMainThread(() => TableView.ScrollToRow(indexPath, UIKit.UITableViewScrollPosition.Middle, true)); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var source = new LanguageTableViewSource(TableView, ViewModel.Languages); source.ElementSelected.OfType <LanguageItemViewModel>().Subscribe(x => ViewModel.SelectedLanguage = x); TableView.Source = source; }
public override void ViewDidLoad() { base.ViewDidLoad(); var source = new LanguageTableViewSource(TableView, ViewModel.Items); TableView.Source = source; OnActivation(d => { d(this.WhenAnyObservable(x => x.ViewModel.LoadCommand.IsExecuting) .Where(x => !x).Take(1).SubscribeSafe(_ => ScrollToSelected())); d(source.ElementSelected.OfType <LanguageItemViewModel>() .Subscribe(y => ViewModel.SelectedLanguage = y)); d(this.WhenAnyValue(x => x.ViewModel.DismissCommand) .ToBarButtonItem(UIBarButtonSystemItem.Done, x => NavigationItem.LeftBarButtonItem = x)); }); }