コード例 #1
0
        /// <inheritdoc />
        public override void UpdateConstraints()
        {
            base.UpdateConstraints();

            _textLabel.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultHigh, UILayoutConstraintAxis.Vertical);
            _layerLegend.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultHigh, UILayoutConstraintAxis.Vertical);
            _listView.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultHigh, UILayoutConstraintAxis.Vertical);

            if (_constraintsUpdated)
            {
                return;
            }

            _constraintsUpdated = true;
            var margin = ContentView.LayoutMarginsGuide;

            _textLabel.LeadingAnchor.ConstraintEqualTo(margin.LeadingAnchor).Active   = true;
            _layerLegend.LeadingAnchor.ConstraintEqualTo(margin.LeadingAnchor).Active = true;
            _listView.LeadingAnchor.ConstraintEqualTo(margin.LeadingAnchor).Active    = true;

            if (_textLabel.IntrinsicContentSize.Height > 0)
            {
                _textLabel.TopAnchor.ConstraintEqualTo(margin.TopAnchor).Active = true;
            }

            if (_layerLegend.IntrinsicContentSize.Height > 0)
            {
                var bottomAnchor = (_textLabel.IntrinsicContentSize.Height > 0) ? _textLabel.BottomAnchor : margin.BottomAnchor;
                _layerLegend.TopAnchor.ConstraintEqualTo(bottomAnchor).Active = true;
            }

            if (_listView.ContentSize.Height > 0)
            {
                var bottomAnchor = _layerLegend.IntrinsicContentSize.Height > 0 ? _layerLegend.BottomAnchor :
                                   (_textLabel.IntrinsicContentSize.Height > 0) ? _textLabel.BottomAnchor : margin.BottomAnchor;
                _listView.TopAnchor.ConstraintEqualTo(bottomAnchor).Active = true;
            }

            var marginBottomAnchor = _listView.ContentSize.Height > 0 ? _listView.BottomAnchor :
                                     (_layerLegend.IntrinsicContentSize.Height > 0) ? _layerLegend.BottomAnchor :
                                     (_textLabel.IntrinsicContentSize.Height > 0) ? _textLabel.BottomAnchor :
                                     margin.BottomAnchor;

            marginBottomAnchor.ConstraintEqualTo(margin.BottomAnchor).Active = true;
        }