public override void MovedToSuperview() { base.MovedToSuperview(); TopAnchor.ConstraintEqualTo(Superview.TopAnchor).Active = true; WidthAnchor.ConstraintEqualTo(Superview.WidthAnchor).Active = true; CenterXAnchor.ConstraintEqualTo(Superview.CenterXAnchor).Active = true; //Actual value is set with bindings a few lines below var heightConstraint = HeightAnchor.ConstraintEqualTo(1); heightConstraint.Active = true; prepareTitleLabel(); prepareSuggestionViews(); SetNeedsLayout(); LayoutIfNeeded(); this.DelayBind(() => { var heightConverter = new CollectionSizeToHeightConverter <Suggestion>( emptyHeight: emptyHeight, heightPerElement: suggestionHeight + distanceBetweenSuggestions, additionalHeight: distanceAbowTitleLabel + distanceBelowTitleLabel + (float)titleLabel.Frame.Height ); heightConverter.MaxCollectionSize = suggestionViews.Count; var bindingSet = this.CreateBindingSet <SuggestionsView, SuggestionsViewModel>(); bindingSet.Bind(this) .For(v => v.BindVisibility()) .To(vm => vm.IsEmpty); bindingSet.Bind(heightConstraint) .For(c => c.BindConstant()) .To(vm => vm.Suggestions) .WithConversion(heightConverter); for (int i = 0; i < suggestionViews.Count; i++) { bindingSet.Bind(suggestionViews[i]) .For(v => v.Suggestion) .To(vm => vm.Suggestions[i]); } bindingSet.Apply(); }); }
public override void MovedToSuperview() { base.MovedToSuperview(); TopAnchor.ConstraintEqualTo(Superview.TopAnchor).Active = true; WidthAnchor.ConstraintEqualTo(Superview.WidthAnchor).Active = true; CenterXAnchor.ConstraintEqualTo(Superview.CenterXAnchor).Active = true; //Actual value is set with bindings a few lines below heightConstraint.Active = true; prepareTitleLabel(); LayoutIfNeeded(); }