Ejemplo n.º 1
0
        public static SimpleViewHolder FromFormsView(View formsView, Context context, Func <int> width, Func <int> height)
        {
            var itemContentControl = new SizedItemContentView(context, width, height);

            itemContentControl.RealizeContent(formsView);
            return(new SimpleViewHolder(itemContentControl, formsView));
        }
Ejemplo n.º 2
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var context = parent.Context;

            if (EmptyViewTemplate == null)
            {
                if (!(EmptyView is View formsView))
                {
                    // No template, EmptyView is not a Forms View, so just display EmptyView.ToString
                    return(new EmptyViewHolder(CreateTextView(EmptyView?.ToString(), context), null));
                }

                // EmptyView is a Forms View; display that
                var itemContentControl = new SizedItemContentView(CreateRenderer(formsView, context), context,
                                                                  () => parent.Width, () => parent.Height);
                return(new EmptyViewHolder(itemContentControl, formsView));
            }

            // We have a template, so create a view from it
            var templateElement             = EmptyViewTemplate.CreateContent() as View;
            var templatedItemContentControl = new SizedItemContentView(CreateRenderer(templateElement, context),
                                                                       context, () => parent.Width, () => parent.Height);

            return(new EmptyViewHolder(templatedItemContentControl, templateElement));
        }
Ejemplo n.º 3
0
        public static SimpleViewHolder FromFormsView(View formsView, Context context, Func <int> width, Func <int> height, ItemsView container)
        {
            var itemContentControl = new SizedItemContentView(context, width, height);

            // Make sure the Visual property is available during renderer creation
            Internals.PropertyPropagationExtensions.PropagatePropertyChanged(null, formsView, container);
            itemContentControl.RealizeContent(formsView);

            return(new SimpleViewHolder(itemContentControl, formsView));
        }
Ejemplo n.º 4
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var context = parent.Context;

            var template = EmptyViewTemplate;

            if (template == null)
            {
                if (!(EmptyView is View formsView))
                {
                    // No template, EmptyView is not a Forms View, so just display EmptyView.ToString
                    return(new EmptyViewHolder(CreateTextView(EmptyView?.ToString(), context), null));
                }

                // EmptyView is a Forms View; display that
                var itemContentControl = new SizedItemContentView(context, () => parent.Width, () => parent.Height);
                itemContentControl.RealizeContent(formsView);
                return(new EmptyViewHolder(itemContentControl, formsView));
            }

            var itemContentView = new SizedItemContentView(parent.Context, () => parent.Width, () => parent.Height);

            return(new TemplatedItemViewHolder(itemContentView, template));
        }