internal override int IndexFromContainerInner(DependencyObject container) { if (_isProcessingReorder) { // When we process a re-ordering, the "attached" indexes (IndexForItemContainerProperty) are known to be valid, // but the native (NativePanel) is not (moved item is still at it's original location / index). return(base.IndexFromContainerInner(container)); } if (NativePanel != null) { var selectorItem = container as SelectorItem; if (selectorItem == null) { return(-1); } if (selectorItem.LayoutParameters is RecyclerView.LayoutParams) { var displayPosition = NativePanel.GetChildLayoutPosition(selectorItem); var index = ConvertDisplayPositionToIndex(displayPosition); return(index); } } return(base.IndexFromContainerInner(container)); }
public void ScrollIntoView(object item, ScrollIntoViewAlignment alignment) { var index = IndexFromItem(item); var displayPosition = ConvertIndexToDisplayPosition(index); NativePanel?.ScrollIntoView(displayPosition, alignment); }
private void ReplaceGroup(int groupIndexInView) { NativePanel?.ReloadSections(NSIndexSet.FromIndex(groupIndexInView)); if (ManagedVirtualizingPanel != null) { Refresh(); } }
/// <summary> /// Add a group using the native in-place modifier. /// </summary> /// <param name="groupIndexInView">The index of the group from the native collection view's perspective, ie ignoring empty groups /// if HidesIfEmpty=true.</param> private void AddGroup(int groupIndexInView) { NativePanel?.InsertSections(NSIndexSet.FromIndex(groupIndexInView)); if (ManagedVirtualizingPanel != null) { Refresh(); } }
public void ScrollIntoView(object item, ScrollIntoViewAlignment alignment) { // Dispatching ScrollIntoView on Android prevents issues where layout/render changes // occuring during scrolling are not always properly picked up by the layouting/rendering engine. Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var index = IndexFromItem(item); var displayPosition = ConvertIndexToDisplayPosition(index); NativePanel?.ScrollIntoView(displayPosition, alignment); }); }
protected internal override IEnumerable <DependencyObject> GetItemsPanelChildren() { if (NativePanel != null) { return(NativePanel.GetChildren().OfType <DependencyObject>()); } else { return(base.GetItemsPanelChildren()); } }
private void Refresh() { NativePanel?.Refresh(); if (ManagedVirtualizingPanel != null) { ManagedVirtualizingPanel.GetLayouter().Refresh(); InvalidateMeasure(); } }
public void ScrollIntoView(object item) { if (NativePanel != null) { NativePanel.ScrollIntoView(item); } else if (this.Log().IsEnabled(LogLevel.Warning)) { this.Log().LogWarning($"{nameof(ScrollIntoView)} not supported when using non-virtualizing panels."); } }
private protected override void Refresh() { base.Refresh(); NativePanel?.Refresh(); if (ManagedVirtualizingPanel != null) { ManagedVirtualizingPanel.GetLayouter().Refresh(); InvalidateMeasure(); } }
internal override DependencyObject ContainerFromIndexInner(int index) { if (NativePanel != null) { var indexPath = GetIndexPathFromIndex(index)?.ToNSIndexPath(); if (indexPath != null) { return(NativePanel.ContainerFromIndex(indexPath)); } } return(base.ContainerFromIndexInner(index)); }
internal override int IndexFromContainerInner(DependencyObject container) { if (NativePanel != null) { var nativeContainer = (container as SelectorItem)?.FindFirstParent <ListViewBaseInternalContainer>(); if (nativeContainer == null) { return(-1); } var indexPath = NativePanel.IndexPathForCell(nativeContainer); if (indexPath != null) { return(GetIndexFromIndexPath(indexPath.ToIndexPath())); } } return(base.IndexFromContainerInner(container)); }
internal override int IndexFromContainerInner(DependencyObject container) { if (NativePanel != null) { var selectorItem = container as SelectorItem; if (selectorItem == null) { return(-1); } if (selectorItem.LayoutParameters is RecyclerView.LayoutParams) { var displayPosition = NativePanel.GetChildLayoutPosition(selectorItem); var index = ConvertDisplayPositionToIndex(displayPosition); return(index); } } return(base.IndexFromContainerInner(container)); }
public Rect MakeVisible(UIElement visual, Rect rectangle) { if (visual is FrameworkElement fe) { var scrollRect = new Rect( _occludedRectPadding.Left, _occludedRectPadding.Top, ActualWidth - _occludedRectPadding.Right, ActualHeight - _occludedRectPadding.Bottom ); var visualPoint = UIElement.TransformToVisual(visual, null).TransformPoint(new Point()); var visualRect = new Rect(visualPoint, new Size(fe.ActualWidth, fe.ActualHeight)); var deltaX = Math.Min(visualRect.Left - scrollRect.Left, Math.Max(0, visualRect.Right - scrollRect.Right)); var deltaY = Math.Min(visualRect.Top - scrollRect.Top, Math.Max(0, visualRect.Bottom - scrollRect.Bottom)); NativePanel.SmoothScrollBy(ViewHelper.LogicalToPhysicalPixels(deltaX), ViewHelper.LogicalToPhysicalPixels(deltaY)); } return(rectangle); }
partial void OnApplyTemplatePartial() { var source = new ListViewBaseSource(NativePanel); NativePanel.Source = source; NativePanel.NativeLayout.Source = new WeakReference <ListViewBaseSource>(NativePanel.Source); BindToPanel(nameof(ItemsSource)); NativePanel.AnimateScrollIntoView = AnimateScrollIntoView; var disposables = new CompositeDisposable(); Action headerFooterCallback = () => NativePanel?.UpdateHeaderAndFooter(); RegisterCallback(HeaderProperty, headerFooterCallback).DisposeWith(disposables); RegisterCallback(HeaderTemplateProperty, headerFooterCallback).DisposeWith(disposables); RegisterCallback(FooterProperty, headerFooterCallback).DisposeWith(disposables); RegisterCallback(FooterTemplateProperty, headerFooterCallback).DisposeWith(disposables); _callbackSubscriptions.Disposable = disposables; }
private protected override void Refresh() { base.Refresh(); NativePanel?.Refresh(); }
/// <summary> /// Add a group using the native in-place modifier. /// </summary> /// <param name="groupIndexInView">The index of the group from the native collection view's perspective, ie ignoring empty groups /// if HidesIfEmpty=true.</param> private void AddGroup(int groupIndexInView) { NativePanel?.InsertSections(NSIndexSet.FromIndex(groupIndexInView)); }
public override void ScrollTo(int x, int y) { NativePanel?.ScrollTo(x, y); }
private void Refresh() { NativePanel?.Refresh(); }
void IScrollContentPresenter.SmoothScrollTo(int physicalDeltaX, int physicalDeltaY) => NativePanel?.SmoothScrollTo(physicalDeltaX, physicalDeltaY);
/// <summary> /// Bind a property on the native collection panel to its equivalent on ListViewBase /// </summary> private void BindToPanel(string propertyName, BindingMode bindingMode = BindingMode.OneWay) { NativePanel.Binding(propertyName, propertyName, this, bindingMode); }
private void ReplaceGroup(int groupIndexInView) { NativePanel?.ReloadSections(NSIndexSet.FromIndex(groupIndexInView)); }
private void RemoveGroup(int groupIndexInView) { NativePanel?.DeleteSections(NSIndexSet.FromIndex(groupIndexInView)); }
public void SmoothScrollTo(int x, int y) { NativePanel?.SmoothScrollTo(x, y); }
public override bool DispatchTouchEvent(MotionEvent e) { NativePanel?.TrackMotionDirections(e); return(base.DispatchTouchEvent(e)); }
private void RemoveItems(int firstItem, int count, int section) { NativePanel?.DeleteItems(GetIndexPathsFromStartAndCount(firstItem, count, section)); ManagedVirtualizingPanel?.GetLayouter().RemoveItems(firstItem, count, section); }
partial void NativeReplaceItems(int firstItem, int count, int section) { NativePanel?.ReloadItems(GetIndexPathsFromStartAndCount(firstItem, count, section)); }
private void AddItems(int firstItem, int count, int section) { NativePanel?.InsertItems(GetIndexPathsFromStartAndCount(firstItem, count, section)); }
private ContentControl ContainerFromGroupIndex(int groupIndex) { return(NativePanel?.ContainerFromGroupIndex(NSIndexPath.FromRowSection(0, groupIndex))); }
private void RemoveItems(int firstItem, int count, int section) { NativePanel?.DeleteItems(GetIndexPathsFromStartAndCount(firstItem, count, section)); }