private static Size GetConstrainedSize(ILayoutable layoutable, Rect withoutMargins) { var width = GetWidth(layoutable.GetLayoutSizes(), withoutMargins); var height = GetWidth(layoutable.GetLayoutSizes().Swap(), withoutMargins.Swap()); var finalSize = new Size(width, height); return finalSize; }