Proposal: New GridUnitType for Proportional Dimensions in .NET MAUI #23407
Unanswered
VictorWilcox2000
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Introduction
I propose introducing a new GridUnitType called Proportional to allow specifying row heights and column widths proportional to their perpendicular dimensions in .NET MAUI. This would enhance the flexibility and responsiveness of grid layouts.
Problem Statement
Currently, GridUnitType supports Absolute, Auto, and Star sizing. However, there is no option to define a row height as a ratio of column width, or vice versa, which limits certain responsive layout scenarios. One common use case is creating square cells where the width should match the height, regardless of how the content lays out. The current options do not easily support this need.
Proposed Solution
Add a new GridUnitType.Proportional value that allows specifying row heights and column widths as a proportion of their perpendicular dimensions. The values could be defined in XAML using a P suffix, similar to the star sizing notation. This would enable developers to easily create square cells by setting the width to match the row height and allow any other desired ratios.
Example Usage
Implementation Details
Extend the GridUnitType enumeration to include Proportional.
Modify RowDefinition and ColumnDefinition to support the new type.
Implement custom parsing logic for values ending with P.
Benefits
Enhanced Layout Flexibility: Allows for the creation of responsive grid layouts that can adapt to various content and screen sizes.
Square Cells: Easily create square cells by setting column width proportional to row height, making it straightforward to ensure consistent dimensions.
Custom Ratios: Beyond squares, this feature allows for any proportional ratio, offering greater design flexibility.
Consistency with Responsive Design Principles: Ensures that grid layouts are adaptable and maintain their integrity across different devices and orientations.
Beta Was this translation helpful? Give feedback.
All reactions