예제 #1
0
        public static SimpleViewHolder FromFormsView(View formsView, Context context)
        {
            var itemContentControl = new ItemContentView(context);

            itemContentControl.RealizeContent(formsView);
            return(new SimpleViewHolder(itemContentControl, formsView));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
 public TemplatedItemViewHolder(ItemContentView itemContentView, DataTemplate template,
                                bool isSelectionEnabled = true) : base(itemContentView, isSelectionEnabled)
 {
     _itemContentView = itemContentView;
     _template        = template;
 }