public ListViewDataSource(ListViewRenderer.ListViewDataSource source) { this.uiTableViewController = source.uiTableViewController; this.list = source.list; this.uiTableView = source.uiTableView; this.defaultSectionHeight = source.defaultSectionHeight; this.selectionFromNative = source.selectionFromNative; this.Counts = new Dictionary <int, int> (); }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == ListView.RowHeightProperty.PropertyName) { this.UpdateRowHeight(); } else if (e.PropertyName == ListView.IsGroupingEnabledProperty.PropertyName) { this.dataSource.UpdateGrouping(); } else if (e.PropertyName == ListView.HasUnevenRowsProperty.PropertyName) { this.estimatedRowHeight = false; this.dataSource = this.Element.HasUnevenRows ? new ListViewRenderer.UnevenListViewDataSource(this.dataSource) : new ListViewRenderer.ListViewDataSource(dataSource); this.Control.Source = dataSource; } else if (e.PropertyName == ListView.IsPullToRefreshEnabledProperty.PropertyName) { this.UpdatePullToRefreshEnabled(); } else if (e.PropertyName == ListView.IsRefreshingProperty.PropertyName) { this.UpdateIsRefreshing(); } else if (e.PropertyName == ListView.SeparatorColorProperty.PropertyName) { this.UpdateSeparatorColor(); } else if (e.PropertyName == ListView.SeparatorVisibilityProperty.PropertyName) { this.UpdateSeparatorVisibility(); } else if (e.PropertyName == "HeaderElement") { this.UpdateHeader(); } else if (e.PropertyName == "FooterElement") { this.UpdateFooter(); } else { if (!(e.PropertyName == "RefreshAllowed")) { return; } this.UpdatePullToRefreshEnabled(); } }
public UnevenListViewDataSource(ListViewRenderer.ListViewDataSource source) : base(source) { }
protected override void OnElementChanged(ElementChangedEventArgs <ListView> e) { ListViewRenderer.ListViewDataSource unevenListViewDataSource; this.requestedScroll = null; if (e.OldElement != null) { ListView oldElement = e.OldElement; VisualElement headerElement = (VisualElement)((IListViewController)oldElement).HeaderElement; if (headerElement != null) { headerElement.MeasureInvalidated -= new EventHandler(this.OnHeaderMeasureInvalidated); } VisualElement footerElement = (VisualElement)((IListViewController)oldElement).FooterElement; if (footerElement != null) { footerElement.MeasureInvalidated -= new EventHandler(this.OnFooterMeasureInvalidated); } // Not for Mac //e.OldElement.ScrollToRequested -= new EventHandler<ScrollToRequestedEventArgs> (this.OnScrollToRequested); // TODO: TemplatedItems //e.OldElement.TemplatedItems.CollectionChanged -= OnCollectionChanged; //e.OldElement.TemplatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged; } if (e.NewElement != null) { if (base.Control == null) { tableViewController = new FormsUITableViewController(e.NewElement); base.SetNativeControl(tableViewController.TableView); // Not for Mac /* * this.insetTracker = new KeyboardInsetTracker ( * this.tableViewController.TableView, () => base.Control.Window, * (UIEdgeInsets insets) => * { * UITableView control = base.Control; * UIEdgeInsets uIEdgeInset = insets; * UIEdgeInsets uIEdgeInset1 = uIEdgeInset; * base.Control.ScrollIndicatorInsets = uIEdgeInset; * control.ContentInset = uIEdgeInset1; * }, * (CGPoint point) => * { * CGPoint contentOffset = base.Control.ContentOffset; * contentOffset.Y = contentOffset.Y + point.Y; * base.Control.SetContentOffset (contentOffset, true); * }); */ } this.shouldEstimateRowHeight = true; if (e.NewElement.TakePerformanceHit) { this.shouldEstimateRowHeight = false; } e.NewElement.ScrollToRequested += new EventHandler <ScrollToRequestedEventArgs> (this.OnScrollToRequested); e.NewElement.TemplatedItems.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnCollectionChanged); e.NewElement.TemplatedItems.GroupedCollectionChanged += new NotifyCollectionChangedEventHandler(this.OnGroupedCollectionChanged); this.UpdateRowHeight(); var uITableView = base.Control; if (e.NewElement.HasUnevenRows) { unevenListViewDataSource = new ListViewRenderer.UnevenListViewDataSource(e.NewElement, this.tableViewController); } else { unevenListViewDataSource = new ListViewRenderer.ListViewDataSource(e.NewElement, this.tableViewController); } ListViewRenderer.ListViewDataSource listViewDataSource = unevenListViewDataSource; this.dataSource = unevenListViewDataSource; uITableView.Source = listViewDataSource; //this.UpdateEstimatedRowHeight (); this.UpdateHeader(); this.UpdateFooter(); this.UpdatePullToRefreshEnabled(); this.UpdateIsRefreshing(); this.UpdateSeparatorColor(); this.UpdateSeparatorVisibility(); object selectedItem = e.NewElement.SelectedItem; if (selectedItem != null) { this.dataSource.OnItemSelected(null, new SelectedItemChangedEventArgs(selectedItem)); } } base.OnElementChanged(e); }