- Edited dimauto.md

This commit is contained in:
Tig
2024-04-30 15:59:39 -06:00
parent 2fafc6929f
commit beec30a135

View File

@@ -12,8 +12,15 @@ The `DimAutoStyle` enum defines the different ways that `Dim.Auto` can be used t
## Using Dim.Auto
`Dim.Auto` is defined as:
```cs
public static Dim Auto (DimAutoStyle style = DimAutoStyle.Auto, Dim min = null, Dim max = null)
```
To use `Dim.Auto`, set the `Width` or `Height` property of a view to `Dim.Auto (DimAutoStyle.Text)` or `Dim.Auto (DimAutoStyle.Content)`.
For example, to create a `View` that is sized based on the `Text` property, you can do this:
```cs
@@ -40,6 +47,23 @@ view.Add (new Label () { Text = "Hello, World!" });
In this example, the `View` will be sized based on the size of the `Label` that is added to it.
### Specifying a miniumum size
You can specify a minimum size by passing a `Dim` object to the `min` parameter. For example, to create a `View` that is sized based on the `Text` property, but has a minimum width of 10 columns, you can do this:
```cs
View view = new ()
{
Text = "Hello, World!",
Width = Dim.Auto (DimAutoStyle.Text, min: Dim.Absolute (10)),
Height = Dim.Auto (DimAutoStyle.Text),
};
```
### Specifying a maximum size
> NOT YET IMPLEMENTED
## Limitations
`Dim.Auto` is not always the best choice for sizing a view. For example, if you want a view to fill the entire width of the Superview, you should use `Dim.Fill ()` instead of `Dim.Auto (DimAutoStyle.Content)`.