public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { var isHeader = holder is WFGroupHeaderViewHolder; var itemView = holder.ItemView; var element = (itemView as VisualElementRenderer <View>).Element; var dpHeight = 0; int pxHeight; var dpWidth = (int)ItemWidth; if (holder is WFHeaderViewHolder) { dpHeight = (int)Element.Header.HeightRequest; element.Layout(new Rectangle(0, 0, Element.Width, dpHeight)); pxHeight = DroidUtils.DpToPixel(dpHeight); var pxWidth = DroidUtils.DpToPixel((int)Element.Width); var layoutParams = new ViewGroup.LayoutParams(pxWidth, pxHeight); itemView.LayoutParameters = layoutParams; itemView.Layout(0, 0, pxWidth, pxHeight); var lParams = new StaggeredGridLayoutManager.LayoutParams(itemView.LayoutParameters); lParams.FullSpan = true; itemView.LayoutParameters = lParams; return; } if (Element.Header != null) { position--; //because the first index is the Header View } element.BindingContext = SourceList[position]; if (holder is WFGroupHeaderViewHolder) { (holder as WFGroupHeaderViewHolder).BindingContext = element.BindingContext; dpHeight = (int)Element.HeaderTemplateHeight; element.Layout(new Rectangle(0, 0, Element.Width, dpHeight)); pxHeight = DroidUtils.DpToPixel(dpHeight); var pxWidth = DroidUtils.DpToPixel((int)Element.Width); var layoutParams = new ViewGroup.LayoutParams(pxWidth, pxHeight); itemView.LayoutParameters = layoutParams; itemView.Layout(0, 0, pxWidth, pxHeight); var lParams = new StaggeredGridLayoutManager.LayoutParams(itemView.LayoutParameters); lParams.FullSpan = true; itemView.LayoutParameters = lParams; } else { (holder as WFViewHolder).BindingContext = element.BindingContext; if (Element.GetHeightForCellDelegate != null) { dpHeight = (int)Element.GetHeightForCellDelegate(SourceList[position]); } else { dpHeight = _heights[position]; } element.Layout(new Rectangle(0, 0, dpWidth, dpHeight)); pxHeight = DroidUtils.DpToPixel(dpHeight); var pxWidth = DroidUtils.DpToPixel((int)ItemWidth); var layoutParams = new ViewGroup.LayoutParams(pxWidth, pxHeight); itemView.LayoutParameters = layoutParams; itemView.Layout(0, 0, pxWidth, pxHeight); } }
public static void Init(Context context) { _context = context; DroidUtils.Init(context); FormsView_Utils.Init(context); }