[Spec] drop AndExpand layout option
See original GitHub issueDescription
The AndExpand suffix on some LayoutOptions is confusing at best, harmful and expensive at its worst.
It only make sense to have a single element (per axis) with AndExpand flag set, and only for a handful of layouts (StackLayout and Grid, mainly).
If a layout contains multiple expandable children per direction:
- it should warn the user
- all but the last one (in the direction) should be ignored
We could also optimize the layouts for these restrictions (reducing the measure for expand items, e.g.).
API
struct LayoutOptions,
Remove or [Obsolete]
class LayoutOptionsConverter
Remove or [Obsolete]
enum LayoutExpandFlag
Remove or [Obsolete]
class View
Properties and BindableProperties
Replace Vertical|HorizontalOptions[Property]
by Vertical|HorizontalAlignment[Property]
API | Description |
---|---|
public LayoutAlignment VerticalAlignment | Gets or sets the verticalAlignemnt. |
public LayoutAlignment HorizontalAlignment | Gets or sets the verticalAlignemnt. |
public static readonly BindableProperty VerticalAlignmentProperty | bp for VerticalAlignemnt |
public static readonly BindableProperty HorizontalAlignmentProperty | bp for HorizontalAlignemnt |
Add bool Vertical|HorizontalExpand[Property]
. An attached BindableProperty would be more suited, as technically the Expand is only valid within some layouts, but the syntax would be harder for the user.
Scenarios
C# Example
var button = new Button();
button.ExpandVertically = true;
button.VerticalAlignment = LayoutAlignment.Center;
XAML Example
<Button x:Name="thing" ExpandVertically="true" VerticalAlignemnt="Center" />
CSS Example
Expansion is not supported in CSS
Backward Compatibility
Minimum API levels: N/A
Breaking changes: this require some modification in user XAML and code. The rule about a single expandable might produce different results than what we actually have.
Difficulty : medium
Issue Analytics
- State:
- Created 3 years ago
- Reactions:22
- Comments:5 (3 by maintainers)
Is it not better to use a weight system?
So if I have a stack with 3 items, and each has a VerticalOptions of Fill, then each gets the current height.
If I set them all to be Weight=1, then it overrides the space because it will do a RemainingHeight/3 and then set that to be the height. Even if the first item say requires 90% of the space?
Take a look to the discussion here: https://github.com/dotnet/maui/discussions/3324