private void Update() { var contentItem = _sourcePropertyFunc(); var view = _targetPropertyFunc(); if (contentItem == null || view == null) { return; } _contentItemViewHolder?.Dispose(); var contentItemContainer = view.FindViewById <ViewGroup>(Resource.Id.contentItem_container); if (contentItemContainer == null) { throw new ArgumentException("ContentItemBinding requires a view with a ViewGroup with id contentItem_container"); } var displayContext = new DisplayContext(); displayContext.Activity = _activity; displayContext.Inflater = _activity.LayoutInflater; displayContext.Messenger = Messenger.Default; displayContext.RootContainer = contentItemContainer; displayContext.RootContentItem = contentItem; displayContext.ViewHolderFactory = new DefaultViewHolderFactory(displayContext); displayContext.Messenger.Send(new ContentItemDisplayingMessage(displayContext)); _contentItemViewHolder = displayContext.RootContentItemViewHolder(); contentItemContainer.AddView(_contentItemViewHolder.View); }
public void Bind(IContentItem contentItem) { _contentItemViewHolder?.Dispose(); var container = ItemView.FindViewById <ViewGroup>(Resource.Id.contentItem_container); _contentItemViewHolder = _displayContext.ViewHolderFactory.CreateContentItemViewHolder(container, contentItem); container.AddView(_contentItemViewHolder.View); }
public override void Dispose() { base.Dispose(); _contentItemViewHolder?.Dispose(); }