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

            var content = (View)template.CreateContent();

            var linearLayout = new LinearLayoutWithFocus(parent.Context)
            {
                Orientation      = Orientation.Vertical,
                LayoutParameters = new RecyclerView.LayoutParams(LP.MatchParent, LP.WrapContent),
                Content          = content
            };

            var bar = new AView(parent.Context);

            bar.SetBackgroundColor(Colors.Black.MultiplyAlpha(0.14f).ToPlatform());
            bar.LayoutParameters = new LP(LP.MatchParent, (int)parent.Context.ToPixels(1));
            linearLayout.AddView(bar);

            var container = new ShellContainerView(parent.Context, content, MauiContext);

            container.MatchWidth       = true;
            container.LayoutParameters = new LP(LP.MatchParent, LP.WrapContent);
            linearLayout.AddView(container);

            return(new ElementViewHolder(content, linearLayout, bar, _selectedCallback, _shellContext.Shell));
        }
Exemplo n.º 2
0
        public override AView GetView(int position, AView convertView, ViewGroup parent)
        {
            var item = ListProxy[position];

            ShellContainerView result = null;

            if (convertView != null)
            {
                result = convertView as ShellContainerView;
                result.View.BindingContext = item;
            }
            else
            {
                var template = _searchHandler.ItemTemplate ?? DefaultTemplate;
                var view     = (View)template.CreateContent(item, _shellContext.Shell);
                view.BindingContext = item;

                result               = new ShellContainerView(parent.Context, view, MauiContext);
                result.MatchWidth    = true;
                result.MeasureHeight = true;
            }

            return(result);
        }