Ejemplo n.º 1
0
        private View GetItemView(int position, View convertView, int templateId)
        {
            if (AdjustPosition(position) >= ItemsSource.Count())
            {
                return(null);
            }

            if (templateId == 0)
            {
                var view   = convertView;
                var source = GetRawItem(position);

                if (view == null)
                {
                    var template = Windows.UI.Xaml.DataTemplateHelper.ResolveTemplate(
                        this.ItemTemplate,
                        this.ItemTemplateSelector,
                        source,
                        null
                        );

                    view            = template?.LoadContentCached();
                    view.Click     += ItemViewClicked;
                    view.LongClick += ItemViewLongClicked;
                }

                view.Tag = position.ToStringInvariant();
                var bindable = view as IDataContextProvider;

                if (bindable != null)
                {
                    bindable.DataContext = GetRawItem(position);
                }

                return(view);
            }
            else
            {
                var bindableView = convertView as BindableView;

                if (bindableView.SelectOrDefault(v => v.LayoutId != templateId, true))
                {
                    bindableView            = new BindableView(Context, templateId);
                    bindableView.Click     += ItemViewClicked;
                    bindableView.LongClick += ItemViewLongClicked;
                }

                bindableView.Tag         = position.ToString(CultureInfo.InvariantCulture);
                bindableView.DataContext = GetRawItem(position);

                return(bindableView);
            }
        }
Ejemplo n.º 2
0
        private View CreateView(Android.Content.Context context, int templateId, object source)
        {
            BindableView view = null;

            if (templateId != 0)
            {
                view             = new BindableView(context, templateId);
                view.DataContext = source;
            }

            return(view);
        }
Ejemplo n.º 3
0
        protected virtual View GetBindableView(View convertView, object source, int templateId, ViewGroup parent)
        {
            if (templateId == 0)
            {
                // no template seen - so use a standard string view from Android and use ToString()
                return(GetSimpleView(convertView, source));
            }

            var bindableView = convertView as BindableView;

            if (convertView == null)
            {
                bindableView = new BindableView(parent.Context, templateId);
            }

            bindableView.DataContext = source;

            return(bindableView);
        }
Ejemplo n.º 4
0
        protected virtual View GetBindableView(View convertView, object source, ViewGroup parent, int templateId)
        {
            if (templateId == 0)
            {
                // no template seen - so use a standard string view from Android and use ToString()
                var view = GetSimpleView(convertView, source, parent);

                var bindable = view as IDataContextProvider;

                var viewGroup = view as ViewGroup;
                if (viewGroup != null)
                {
                    // This is here to avoid disabling the ItemClick event when an Item Template has a button
                    // as any of its children.
                    viewGroup.DescendantFocusability = Android.Views.DescendantFocusability.BlockDescendants;
                }

                if (bindable != null)
                {
                    bindable.DataContext = source;
                }

                return(view);
            }

            var bindableView = convertView as BindableView;

            if (convertView == null || bindableView.LayoutId != templateId)
            {
                bindableView = new BindableView(_context, templateId);

                _allocatedViews.Add(bindableView);
            }

            bindableView.DataContext = source;

            return(bindableView);
        }
Ejemplo n.º 5
0
 internal Enumerator(_BindableView owner)
 {
     _inner = owner.GetChildrenEnumerator();
 }