Esempio n. 1
0
        /// <summary>
        /// Rows the selected.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="indexPath">Index path.</param>
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            if (_PickerCell.ItemsSource == null)
            {
                tableView.DeselectRow(indexPath, true);
                return;
            }

            _pickerVC?.Dispose();

            var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.KeyWindow.RootViewController);

            if (naviCtrl is ShellSectionRenderer shell)
            {
                // When use Shell, the NativeView is wrapped in a Forms.ContentPage.
                _pickerVC = new PickerTableViewController(this, tableView, shell.ShellSection.Navigation);
                // Fix height broken. For some reason, TableView ContentSize is broken.
                _pickerVC.TableView.ContentInset = new UIEdgeInsets(44, 0, 44, 0);
                var page = new ContentPage();
                page.Content = _pickerVC.TableView.ToView();;
                page.Title   = _PickerCell.PageTitle;

                // Fire manually because INavigation.PushAsync does not work ViewDidAppear and ViewWillAppear.
                _pickerVC.ViewDidAppear(false);
                _pickerVC.InitializeView();
                BeginInvokeOnMainThread(async() => {
                    await shell.ShellSection.Navigation.PushAsync(page, true);
                    _pickerVC.InitializeScroll();
                });
            }
            else
            {
                // When use traditional navigation.
                _pickerVC = new PickerTableViewController(this, tableView);
                BeginInvokeOnMainThread(() => naviCtrl.PushViewController(_pickerVC, true));
            }


            if (!_PickerCell.KeepSelectedUntilBack)
            {
                tableView.DeselectRow(indexPath, true);
            }
        }
        /// <summary>
        /// Rows the selected.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="indexPath">Index path.</param>
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            if (_PickerCell.ItemsSource == null)
            {
                tableView.DeselectRow(indexPath, true);
                return;
            }

            var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.KeyWindow.RootViewController);

            _pickerVC?.Dispose();
            _pickerVC = new PickerTableViewController(this, tableView);
            BeginInvokeOnMainThread(() => naviCtrl.PushViewController(_pickerVC, true));

            if (!_PickerCell.KeepSelectedUntilBack)
            {
                tableView.DeselectRow(indexPath, true);
            }
        }