-
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 MultiColumnsStackPanel #3381
base: main
Are you sure you want to change the base?
Add MultiColumnsStackPanel #3381
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 🙌 |
Thanks @vgromfeld, this is an interesting scenario. I'm trying to think of other panels we have already for this scenario like WrapPanel w/ Orientation Vertical which can do some similar things (outside a ScrollViewer). I guess the difference here is it still tries to put things in columns explicitly? In which case, how does this differ from something like the StaggeredPanel? Is it just the order of the layout, could we add an If we move forward, I think we should align to other common spacing names like |
This looks very much like the WrapPanel. However, when the Orientation is vertical and you have a ScrollViewer that scrolls vertically I don't think it will flow to another column. |
I don't think there's enough overlap in code to share with WrapPanel, but I wonder if we want a common interface for the properties that are shared like |
The main difference is that
I agree, I will update the naming to stay aligned. |
I wonder if we should add support for this in the WrapPanel instead of a new control. We could add a property for evenly distributing items |
@skendrot, there is some overlap in how the two controls are displaying things but the approach is not the same. |
@RosarioPulella, you are rigth about the constraint the control tries to follow:
I agree that there is some overlap between this new control and the existing
I choose to write a new panel to keep the existing ones light and simple. I do agree that we can find a better name. I didn't spend a lot of time on the one I choose but didn't find anything better that @michael-hawker, I updated the sample code to add some |
Thanks @vgromfeld, I think that's been the sticking point is it just feels so close even though the implementations are different. 🙂 I agree just adding a big if/else isn't going to be helpful. Let's keep it separate as you have it in this PR for now. Good to know the buttons were just a test, I just wasn't sure what the desired behavior was as it seemed like a case where a dev might expect them to show up in the same positioning with the different alignments. For naming, wondering if we want to call this It's something I could use in XAML Studio for my settings page too, so maybe it's something I can play with and prototype on one of my streams later... 🤔 |
@vgromfeld I Hope I was not too harsh on the name you chose. But I also think it makes a lot of sense as its own control. One thing I don't understand is why to try to fill the fist columns and leave the rest in the last? If we are trying to make all the other columns as close to each other in height as possible, then why to have one overflow-ish one that we just dump items into. It sounds like it would be more consistent if we just try to make all the columns around the same height. I might not fully understand the driving use case, but is the point of this control to dynamically layout items into columns (near in height to each other) according to a constraint in width? I think that behavior alone is clear to users, but adding the bit about the last column seems inconsistent to me. On a similar note, if the |
@michael-hawker , I like the @RosarioPulella the last/overflow column is mostly an artefact of the implementation. I probably need to improve the logic to have better columns' sizes. For now, the first column is driving everything and sometimes, based on the children heights, I might not get a fully filled last column. I will check if there is something easily doable. |
Thanks, @vgromfeld. That clears up the intended behavior and I am excited to see this control merged 😃! Is it supposed to keep making columns like the |
@RosarioPulella, this is intended. The control tries to fill the full height of the container. If the container becomes so wide that we have more space than needed, only the "first" columns will be filled. |
var columnsCount = 1; | ||
if (columnsWidth < availableWidth) | ||
{ | ||
var additionalColumns = (int)((availableWidth - columnsWidth) / (columnsWidth + HorizontalSpacing)); |
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.
Instead of doing additional columns wouldn't it be better to set the column count to be the result of the available width divided by the column width?
columnsCount = (int)(availableWidth / (columnsWidth + HorizontalSpacing));
VerticalSpacing="@[VerticalSpacing:Slider:8:0-64]" | ||
MaxColumnWidth="@[MaxColumnWidth:Slider:240:0-500]" | ||
Padding="@[Padding:Thickness:0,0,0,0]@"> | ||
<TextBox Header="Field 1" /> |
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.
I think it would be best to generate these in code with random heights and allow the user to add new textboxes. Would be better for testing.
Thanks for taking a look @skendrot, always appreciate your insights in this space! @vgromfeld let us know when you have a chance to get back to looking at feedback, I know you're a bit busy. If you're in no rush too, I could see this spilling over into a 7.1 release so we can coordinate with the WTS folks in the comment I left in #3569 and test this out more with some more form helpers to complete the WinUI story vision... Thoughts? |
Welcome to the Windows Community Toolkit @Loser09sly! We always love to see community folks reviewing features that are being worked on in the Toolkit. Since this is your first interaction with our community, would you mind providing a few more details on what you tried for your review and your first impressions? Thanks a bunch! Look forward to working with you more in the future. |
@vgromfeld thoughts on where we are and what's left to do based on the feedback in the PR? Should we try and get this into 7.0 or hold back and evaluate adding more helpers for a larger story to support microsoft/microsoft-ui-xaml#82 for 7.1 more fully and use that as a test-case for this panel? |
@michael-hawker, we should wait for 7.1 and see how we can integrate some of the form control elements in it. |
@vgromfeld Thanks for the input. @michael-hawker will add this in 7.1 for now and then will proceed from there. |
In one of my app, I have a very long form containing a lot of fields. I usually limit the width of the fields to have something not to big. To fill the rest of the screen, we can use adaptive visual state triggers but it is not that convenient.
In this PR, I'm proposing a multi columns stack panel that will automatically display its children in columns of equal height.
This control works best when used inside a vertical
ScrollViewer
but can also be used without.PR Type
What kind of change does this PR introduce?
What is the new behavior?
Add a new
MultiColumnsStackPanel
. It exposes the following properties:ItemsSpacing
: the vertical space between the child elementsColumnsSpacing
: the horizontal width between the columnsMaxColumnWidth
: the maximum width for the columns_
HorizontalContentAlignement
: the horizontal alignment for the children. If the child is aControl
we will use itsControl.HorizontalAlignment
value instead.It should still be possibe to improve the algorithm to reduce the number of computation. That's something that can be done later :)
PR Checklist
Please check if your PR fulfills the following requirements: