public static SimpleViewHolder FromFormsView(View formsView, Context context) { var itemContentControl = new ItemContentView(context); itemContentControl.RealizeContent(formsView); return(new SimpleViewHolder(itemContentControl, formsView)); }
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { var context = parent.Context; if (viewType == ItemViewType.GroupHeader) { var itemContentView = new ItemContentView(context); return(new TemplatedItemViewHolder(itemContentView, ItemsView.GroupHeaderTemplate, isSelectionEnabled: false)); } if (viewType == ItemViewType.GroupFooter) { var itemContentView = new ItemContentView(context); return(new TemplatedItemViewHolder(itemContentView, ItemsView.GroupFooterTemplate, isSelectionEnabled: false)); } return(base.OnCreateViewHolder(parent, viewType)); }
protected RecyclerView.ViewHolder CreateHeaderFooterViewHolder(object content, DataTemplate template, Context context) { if (template != null) { var footerContentView = new ItemContentView(context); return(new TemplatedItemViewHolder(footerContentView, template, isSelectionEnabled: false)); } if (content is View formsView) { var viewHolder = SimpleViewHolder.FromFormsView(formsView, context); // Propagate the binding context, visual, etc. from the ItemsView to the header/footer ItemsView.AddLogicalChild(viewHolder.View); return(viewHolder); } // No template, Footer is not a Forms View, so just display Footer.ToString return(SimpleViewHolder.FromText(content?.ToString(), context, fill: false)); }
public TemplatedItemViewHolder(ItemContentView itemContentView, DataTemplate template, bool isSelectionEnabled = true) : base(itemContentView, isSelectionEnabled) { _itemContentView = itemContentView; _template = template; }