void Source_ItemClicked(int row) { object item = SourceList[row]; if (Element.IsGroupingEnabled && HeaderIndexes.Contains(row)) { Element.InvokeHeaderTapped(item); return; } Element.InvokeItemTapped(item); }
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var isHeader = HeaderIndexes.Contains(indexPath.Row); WFCell cell; if (isHeader) { cell = (WFCell)collectionView.DequeueReusableCell(WHeaderCell.CELL_ID, indexPath); } else { cell = (WFCell)collectionView.DequeueReusableCell(WFCell.CELL_ID, indexPath); } if (cell.RendererView == null) { View formsView; if (isHeader) { formsView = (View)HeaderTemplate.CreateContent(); } else { formsView = (View)ItemTemplate.CreateContent(); } var nativeView = formsView.ToUIView(new CGRect(0, 0, cell.Frame.Width, cell.Frame.Height)); cell.RendererView = nativeView; } var subview = cell.ContentView.Subviews[0]; var frame = subview.Frame; //force height to the cell height in case the reusable cell subview have the old height subview.Frame = new CGRect(frame.X, frame.Y, cell.Frame.Width, cell.Frame.Height); var element = (cell.RendererView as VisualElementRenderer <VisualElement>).Element; element.BindingContext = ItemsSource[indexPath.Row]; element.Layout(new Xamarin.Forms.Rectangle(0, 0, cell.Frame.Width, cell.Frame.Height)); return(cell); }
void InitSource() { SourceList.Clear(); HeaderIndexes.Clear(); if (Element.ItemsSource == null) { return; } SourceList.Clear(); if (Element.IsGroupingEnabled) { var index = 0; foreach (var group in Element.ItemsSource) { HeaderIndexes.Add(index); var headerIndex = index; SourceList.Add(group); index++; var groupList = group as IEnumerable; foreach (var item in groupList) { SourceList.Add(item); index++; } } } else { foreach (var item in Element.ItemsSource) { SourceList.Add(item); } } }