-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FrameworkElement.VerticalAlignment and FrameworkElement.HorizontalAlignment support to WrapPanel #3471
Add FrameworkElement.VerticalAlignment and FrameworkElement.HorizontalAlignment support to WrapPanel #3471
Conversation
Thanks vgromfeld for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
I don't see how this solves the original issue. It does provide a work-around but the issue would still persist that if you set the VerticalAlignment on the items it wouldn't be "respected". |
@skendrot I think you're basically saying that a better approach to basically be instead of setting this at the panel level, perform the similar breakout that @vgromfeld does in this PR, but just inspect each child's FrameworkElement alignment properties individually at each arrange call in order to place them in their 'cell'? I think this is feasible and would result in the same desired outcome, eh? This would make things much more flexible and also remove the confusion around having the alignment properties on the panel tied to the orientation property. I think this further shows that we almost need some base panel helpers that perform some of these common layout operations we can use across our solutions, but that's outside of scope here. |
I've removed the two custom properties and will now use the children's alignment values. |
@michael-hawker No, we shouldn't need to inspect the child element alignment at all. What we would need to do is ensure that when we do the layout (arrange), that we give elements all of the available space afforded by the row/column. |
…mfeld/WindowsCommunityToolkit into wrapPanel.verticalAlignment
Thanks @skendrot, I've updated the PR code to give the items the row/column height/width and let them align automatically. <controls:WrapPanel Background="{ThemeResource Brush-Grey-04}"
Padding="0,0,0,0"
VerticalSpacing="20"
HorizontalSpacing="20" >
<Border Width="100" Height="100" Background="Blue"/>
<TextBlock Text="Hello" VerticalAlignment="Center" />
<Border Width="20" Height="20" Background="Green" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
<Border Width="20" Height="20" Background="Yellow" VerticalAlignment="Top" HorizontalAlignment="Right" />
<Button Content="Click me!" VerticalAlignment="Center" HorizontalAlignment="Center" />
<Button Content="Click me!" VerticalAlignment="Stretch" />
</controls:WrapPanel> |
Hello @michael-hawker! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
@Sergio0694 look good now? |
@michael-hawker Yup, all my notes have been addressed now 😄 The CI failed though 👀 |
@vgromfeld StyleCop issue to fix, then you should be good:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@michael-hawker, I've fixed the file. |
@azchohfi looks like the TAEF tests passed but then reported failure? Any idea what might have happened there? |
Closed and re-opened to try and re-trigger build. |
@michael-hawker no idea on what happened. VSTest crashed out of nowhere. Lets see if it passes now. |
This may have changed the default behavior for WrapPanel? We had a user expecting to see Sample App behavior: But saw their items centered in the rows instead (vs. top aligned): Filed issue #3574 |
Fixes #3466
This PR adds the support of the
FrameworkElement.VerticalAlignment
andFrameworkElement.HorizontalAlignment
toWrapPanel
.PR Type
What kind of change does this PR introduce?
What is the current behavior?
The wrap panel is always top/left aligning its children.
What is the new behavior?
The controls will now use the children alignment to properly align them inside their row/column.
The
Arrange
code has been updated and is now a two steps process. The position and size of all the controls are stored in a newUvRect
structure. ThoseUvRect
are grouped byRow
. This allows us to get the final height of the row before drawing the children so we can adjust their position.VerticalAlignment.Top
VerticalAlignment.Center
VerticalAlignment.Bottom
VerticalAlignment.Stretch
PR Checklist
Please check if your PR fulfills the following requirements: