-
Notifications
You must be signed in to change notification settings - Fork 733
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
Grid - support Min/Max-Width/Height on Column/Row-Definitions #1048
Conversation
This is not a complete implementation, for example we don't currently attempt to match UWP in the case that the sum of MinWidths exceeds the available width. Add tests, samples.
858edf0
to
3d95e33
Compare
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.
Nice work !
public class Given_Grid_And_Min_Max | ||
{ | ||
[TestMethod] | ||
public void When_Max_Width_Star() |
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.
All those tests look like good candidates for:
Not a big deal though :)
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.
Yeah true
var totalStarSizedWidth = initialTotalStarSizedWidth; | ||
var unitStarWidth = remainingWidth / totalStarSizedWidth; | ||
|
||
var maxTries = starSizeChildren.Span.Length * 2 + 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.
What's the idea behind maxTries being star children count * 2 + 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.
+1 to always run at least once, star children count because it shouldn't iterate more times than there are star children, *2 for margin of error.
Note that in the case there are no MinWidths or MaxWidths set it will only run once and will behave as before.
/// In either case, we exclude the constrained rows and recalculate for the remaining 'true' star-sized rows. The new unitStarHeight may cause | ||
/// more Min/MaxHeights to kick in, so we repeat until the values stabilize. | ||
Memory<double> starCalculatedPixelRows = null; | ||
for (int i = 0; i <= maxTries; i++) |
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.
If you understand what changes between iterations, you might be able to come up with an algorithm that doesn't need iterations. An example could be to order the columns by their MaxWidth value (ascending) and apply the constraints on that sorted list once.
I updated the related internal issue ;) Thanks @davidjohnoliver, nice work! |
GitHub Issue (If applicable): #1032
PR Type
What kind of change does this PR introduce?
Feature
Adds support for supports
ColumnDefinition.MinWidth
andMaxWidth
andRowDefinition.MinHeight
andMaxHeight
.This is not a complete implementation, for example we don't currently attempt to match UWP in the case that the sum of MinWidths exceeds the available width.
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Other information
Internal Issue (If applicable):