protected override Size MeasureOverride(Size availableSize) { _childGraph.Clear(); foreach (Layoutable child in Children) { if (child == null) { continue; } var node = _childGraph.AddNode(child); node.AlignLeftWithNode = _childGraph.AddLink(node, GetDependencyElement(AlignLeftWithProperty, child)); node.AlignTopWithNode = _childGraph.AddLink(node, GetDependencyElement(AlignTopWithProperty, child)); node.AlignRightWithNode = _childGraph.AddLink(node, GetDependencyElement(AlignRightWithProperty, child)); node.AlignBottomWithNode = _childGraph.AddLink(node, GetDependencyElement(AlignBottomWithProperty, child)); node.LeftOfNode = _childGraph.AddLink(node, GetDependencyElement(LeftOfProperty, child)); node.AboveNode = _childGraph.AddLink(node, GetDependencyElement(AboveProperty, child)); node.RightOfNode = _childGraph.AddLink(node, GetDependencyElement(RightOfProperty, child)); node.BelowNode = _childGraph.AddLink(node, GetDependencyElement(BelowProperty, child)); node.AlignHorizontalCenterWith = _childGraph.AddLink(node, GetDependencyElement(AlignHorizontalCenterWithProperty, child)); node.AlignVerticalCenterWith = _childGraph.AddLink(node, GetDependencyElement(AlignVerticalCenterWithProperty, child)); } _childGraph.Measure(availableSize); _childGraph.Reset(false); var boundingSize = _childGraph.GetBoundingSize(Width.IsNaN(), Height.IsNaN()); _childGraph.Reset(); _childGraph.Measure(boundingSize); return(boundingSize); }
protected override Size MeasureOverride(Size availableSize) { #region Calc DesiredSize _childGraph.Clear(); foreach (UIElement child in InternalChildren) { if (child == null) { continue; } var node = _childGraph.AddNode(child); node.AlignLeftWithNode = _childGraph.AddLink(node, GetAlignLeftWith(child)); node.AlignTopWithNode = _childGraph.AddLink(node, GetAlignTopWith(child)); node.AlignRightWithNode = _childGraph.AddLink(node, GetAlignRightWith(child)); node.AlignBottomWithNode = _childGraph.AddLink(node, GetAlignBottomWith(child)); node.LeftOfNode = _childGraph.AddLink(node, GetLeftOf(child)); node.AboveNode = _childGraph.AddLink(node, GetAbove(child)); node.RightOfNode = _childGraph.AddLink(node, GetRightOf(child)); node.BelowNode = _childGraph.AddLink(node, GetBelow(child)); node.AlignHorizontalCenterWith = _childGraph.AddLink(node, GetAlignHorizontalCenterWith(child)); node.AlignVerticalCenterWith = _childGraph.AddLink(node, GetAlignVerticalCenterWith(child)); } _childGraph.Measure(availableSize); #endregion #region Calc AvailableSize _childGraph.Reset(false); var calcWidth = Width.IsNaN() && HorizontalAlignment != HorizontalAlignment.Stretch; var calcHeight = Height.IsNaN() && VerticalAlignment != VerticalAlignment.Stretch; var boundingSize = _childGraph.GetBoundingSize(calcWidth, calcHeight); _childGraph.Reset(); _childGraph.Measure(boundingSize); return(boundingSize); #endregion }