public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var template = templates.ElementAtOrDefault(viewType);

            var templateContent = template.CreateContent();

            if (templateContent is VirtualViewCell viewCell)
            {
                var viewHolder = new RvItemHolder(viewCell, CreateViewContainer(parent.Context, viewCell.View));

                clickListener = new RvViewHolderClickListener(viewHolder, rvh =>
                {
                    if (rvh.PositionInfo == null || rvh.PositionInfo.Kind != PositionKind.Item)
                    {
                        return;
                    }

                    var p = new ItemPosition(rvh.PositionInfo.SectionIndex, rvh.PositionInfo.ItemIndex);

                    var selected = !rvh.ViewCell.IsSelected;

                    rvh.ViewCell.IsSelected = selected;

                    if (selected)
                    {
                        Element.SetSelected(p);
                    }
                    else
                    {
                        Element.SetDeselected(p);
                    }
                });

                viewHolder.ItemView.SetOnClickListener(clickListener);

                return(viewHolder);
            }

            VirtualViewCell.ThrowInvalidDataTemplateException();
            return(null);
        }
 public RvViewHolderClickListener(RvItemHolder viewHolder, Action <RvItemHolder> clickHandler)
 {
     ViewHolder   = viewHolder;
     ClickHandler = clickHandler;
 }