Skip to content

Commit b797ce8

Browse files
Add comments for added GetDesiredSize override
1 parent 2e99c67 commit b797ce8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Core/src/Handlers/Image/ImageHandler.Windows.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,18 @@ protected override void RemoveContainer()
6060
/// <inheritdoc/>
6161
public override Graphics.Size GetDesiredSize(double widthConstraint, double heightConstraint)
6262
{
63+
// AspectFit + non-Fill alignment: cap Max* to intrinsic bitmap so alignment (Center/Start/End) works.
64+
// Only set once when Max* still Infinity and we have decoded size; else mirror VirtualView Maximum*.
65+
// Without this the Image measures to available space and alignment appears ignored.
6366
if (VirtualView.Aspect == Aspect.AspectFit
6467
&& VirtualView.HorizontalLayoutAlignment != Primitives.LayoutAlignment.Fill
6568
&& VirtualView.VerticalLayoutAlignment != Primitives.LayoutAlignment.Fill)
6669
{
70+
// First (and only) chance to lock to intrinsic size.
6771
if (PlatformView.MaxWidth == double.PositiveInfinity
6872
&& PlatformView.MaxHeight == double.PositiveInfinity)
6973
{
74+
// Clamp to decoded pixel size if available.
7075
var imageSize = GetImageSize();
7176

7277
if (imageSize.Width != 0 && imageSize.Height != 0)
@@ -78,6 +83,7 @@ public override Graphics.Size GetDesiredSize(double widthConstraint, double heig
7883
}
7984
else
8085
{
86+
// Other scenarios: honor user Maximum* values.
8187
if (VirtualView.MaximumHeight != PlatformView.MaxHeight
8288
|| VirtualView.MaximumWidth != PlatformView.MaxWidth)
8389
{

0 commit comments

Comments
 (0)