Beispiel #1
0
        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;
        }