Skip to content

Conversation

@Avid29
Copy link
Contributor

@Avid29 Avid29 commented Dec 3, 2025

Introduces the first draft of the WrapPanel2.

Resolves: #763 as discussed in #762.

@Avid29
Copy link
Contributor Author

Avid29 commented Dec 3, 2025

Demo Video

StretchPanel-Demo1.mp4

@Avid29 Avid29 marked this pull request as draft December 3, 2025 16:48
Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Avid29, great start! I just dropping a couple of quick comments.

There's a few option combinations/scenarios that I may be a bit confused on still with how stretching works, maybe it has to do when both children in a row have a specific fixed size, as it's weird to see them not always be that fixed size. Though I know the video is a little out-of-date too, so not sure if that's a factor.

Not sure if it needs to be part of the doc or some other aspect, but I think it'll be good for us to enumerate a bunch of various settings and scenarios and how we expect their behavior to react to layout and see how that matches up with our expectations on various settings and such. Then we can encode those results in the docs/examples/tests.

(This can be an ongoing process too, as we gather feedback.)

@Avid29 Avid29 marked this pull request as ready for review December 10, 2025 00:28
@Avid29
Copy link
Contributor Author

Avid29 commented Dec 10, 2025

Fixed a bug with Equal children stretching.

Before:
image

After:
image

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments based on the WrapPanel WinUI API review/direction.

/// <summary>
/// Backing <see cref="DependencyProperty"/> for the <see cref="LineSpacing"/> property.
/// </summary>
public static readonly DependencyProperty lineSpacingProperty = DependencyProperty.Register(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed first capital letter

Comment on lines 30 to 35
Equal,

/// <summary>
/// In a row without star-sized items, each item will be stretched proportional to their desired size to fill the row.
/// </summary>
Proportional,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From discussion here: microsoft/microsoft-ui-xaml#10858 (comment)

We're updating to ItemsStretch to match UniformGridLayout. Their enum has Uniform and Fill which I think would be analogs to these defined here, which could be good to match.

Still trying to think about how we reconcile None in the base implementation (i.e. so that this was purely a drop-in replacement when stable). My gut is that None is the StarSizedOnly that we don't have to change that as overriding the attached property to get that behavior is the change in behavior itself... (e.g. in most games, you follow the default rules unless told otherwise, the attached property is a told otherwise extension here basically... [even if the panel is the thing that has to be aware in the implementation, that's an implementation detail])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I see what you mean. I suppose the proper thing to do is name according to the simplest use case and document the extraordinary case as plainly as possible.

Copy link
Contributor Author

@Avid29 Avid29 Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is making me think I should also change the behavior of the ItemJustification property to adjust the margins when ItemsStretch is None. I'll do that in another commit after I address the simple changes. I'm actually really happy with that addition to the API as well.

/// <summary>
/// Gets or sets whether or not all rows/columns should stretch to match the length of the longest.
/// </summary>
public bool FixedRowLengths
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the equivalent of ItemsJustification, is that the direction we should move toward?

Copy link
Contributor Author

@Avid29 Avid29 Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only hesitation was that "justification" is defined by stretching items to touch the margin on both ends. Technically this is not the case unless the main axis stretch is also "Stretch".

Although, since this property applies to the arrange step and not the measure step, arguably the margin is the measured size.

I'll add that rename to my commit addressing your comments, but I'm going to stick with a boolean for now. Especially since that enum seems to have two values with the same description?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, enum is here has 6 values: https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.uniformgridlayoutitemsjustification - even if we only have two for now an enum allows us to add more or change it more easily in the future than a bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I see that. I'm just not sure what the difference between SpaceEvenly and SpaceAround is. They have the same description.

/// <summary>
/// Gets or sets the method used to fill rows without a star-sized item.
/// </summary>
public StretchChildren StretchChildren
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See discussion here: microsoft/microsoft-ui-xaml#10858 (comment)

We're updating to ItemsStretch to match UniformGridLayout.

/// <summary>
/// Items which do not fit within the available space will be removed from the layout.
/// </summary>
Drop,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a scenario/need for this? I'm just curious as it's adding a whole extra property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a potential use case when I was writing this, but I wasn't actually happy with it when I plugged it in. I'll remove the property.

@Avid29
Copy link
Contributor Author

Avid29 commented Dec 16, 2025

Here's the new behavior for when ItemJustification is enabled and ItemsStretch is None.
image

It will override the ItemSpacing to ensure the first and last item are aligned with the margins (if there is only one item it will align to the left margin)

@michael-hawker
Copy link
Member

Cool, ItemSpacing then becomes the minimum as a constraint for layout then in the justification scenario, makes sense! (not sure the best place to call that out on which property, maybe ItemSpacing itself)

@Avid29
Copy link
Contributor Author

Avid29 commented Dec 16, 2025

Cool, ItemSpacing then becomes the minimum as a constraint for layout then in the justification scenario, makes sense! (not sure the best place to call that out on which property, maybe ItemSpacing itself)

Hmm. Maybe worth leaving a remark on both properties, but definitely should be a remark for ItemsSpacing. I think it's thorough enough for ItemsJustificationto just say it forces items to span from margin to margin. It uses a lot of different strategies to do so depending on other properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧪 [Experiment] WrapPanel2

3 participants