コード例 #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 void Bind(object itemBindingContext, ItemsView itemsView,
                         Action <Size> reportMeasure = null, Size?size = null)
        {
            var template = _template.SelectDataTemplate(itemBindingContext, itemsView);

            var templateChanging = template != _selectedTemplate;

            if (templateChanging)
            {
                // Clean up any content we're still holding on to
                _itemContentView.Recycle();

                // Create the new content
                View = (View)template.CreateContent();

                // Set the binding context _before_ we create the renderer; that way, the bound data will be
                // available during OnElementChanged
                View.BindingContext = itemBindingContext;

                // Make sure the Visual property is available when the renderer is created
                PropertyPropagationExtensions.PropagatePropertyChanged(null, View, itemsView);

                // Actually create the native renderer
                _itemContentView.RealizeContent(View);

                _selectedTemplate = template;
            }

            _itemContentView.HandleItemSizingStrategy(reportMeasure, size);

            if (!templateChanging)
            {
                // Same template, new data
                View.BindingContext = itemBindingContext;
            }

            itemsView.AddLogicalChild(View);
        }