protected sealed override Size MeasureCore(Size availableSize) { availableSize -= Margin.Size; availableSize = Size.Combine(availableSize).Bounds(MinSize, MaxSize); Size measuredSize = MeasureOverride(availableSize); measuredSize = Size.Combine(measuredSize).Bounds(MinSize, MaxSize); measuredSize += Margin.Size; return(measuredSize); }
protected sealed override void ArrangeCore(Rect finalRect) { Size finalSize = new Size( HorizontalAlignment != HorizontalAlignment.Stretch ? DesiredSize.Width : finalRect.Width, VerticalAlignment != VerticalAlignment.Stretch ? DesiredSize.Height : finalRect.Height); finalSize -= Margin.Size; finalSize = Size.Combine(finalSize).Bounds(MinSize, MaxSize); Size arrangedSize = ArrangeOverride(finalSize); Point alignedOffset = GetAlignmentOffset(finalRect, arrangedSize + Margin.Size, HorizontalAlignment, VerticalAlignment); Point visualOffset = alignedOffset + Margin.Location; VisualBounds = new Rect(visualOffset, arrangedSize); ActualWidth = arrangedSize.Width; ActualHeight = arrangedSize.Height; ActualSize = arrangedSize; }
protected sealed override void ArrangeCore(Rect finalRect) { Size finalSize = isDefaultAlignment ? finalRect.Size : new Size( HorizontalAlignment != HorizontalAlignment.Stretch ? DesiredSize.Width : finalRect.Width, VerticalAlignment != VerticalAlignment.Stretch ? DesiredSize.Height : finalRect.Height); finalSize -= Margin.Size; if (!layoutTransformValue.IsNullOrIdentity()) { finalSize = layoutTransformValue.GetContainedSize(finalSize); } finalSize = Size.Combine(finalSize).Bounds(MinSize, MaxSize); Size arrangedSize = ArrangeOverride(finalSize); Rect containingRect = new Rect(arrangedSize); if (!layoutTransformValue.IsNullOrIdentity()) { containingRect = layoutTransformValue.GetContainingRect(containingRect); } containingRect = containingRect.AddMargin(Margin); Point alignedOffset = GetAlignmentOffset(finalRect, containingRect.Size, HorizontalAlignment, VerticalAlignment); Point visualOffset = alignedOffset - containingRect.Location; VisualBounds = new Rect(visualOffset, arrangedSize); ActualWidth = arrangedSize.Width; ActualHeight = arrangedSize.Height; ActualSize = arrangedSize; }
protected sealed override Size MeasureCore(Size availableSize) { availableSize -= Margin.Size; if (!layoutTransformValue.IsNullOrIdentity()) { availableSize = layoutTransformValue.GetContainedSize(availableSize); } availableSize = Size.Combine(availableSize).Bounds(MinSize, MaxSize); Size measuredSize = MeasureOverride(availableSize); measuredSize = Size.Combine(measuredSize).Bounds(MinSize, MaxSize); if (!layoutTransformValue.IsNullOrIdentity()) { measuredSize = layoutTransformValue.GetContainingSize(measuredSize); } measuredSize += Margin.Size; return(measuredSize); }