コード例 #1
0
        protected UITableViewCell GetViewForObject(object element)
        {
            UITableViewCell cell = null;

            var viewDef = this.GetViewDefinition(element);

            if (viewDef == null)
            {
                cell = this.GetDefaultView();

                // perform a basic bind to the cell so that we can see that something should be in the table
                cell.TextLabel.Text = element.ToString();
                cell.SetValue(DataContextAttachedProperty.DataContextProperty, element);

                return(cell);
            }

            cell = this.GetViewFromDeclaration(viewDef);

            // if the element is a wrapper, then bind to the wrapped object instead
            var dataContext = element;

            if (element is IDataViewWrapper)
            {
                dataContext = ((IDataViewWrapper)element).Data;
            }

            cell.SetValue(DataContextAttachedProperty.DataContextProperty, dataContext);
            viewDef.Bind(cell, dataContext);

            return(cell);
        }