Aspect Ratio
Keeps its content at a fixed width-to-height ratio.
Installation
bash
shellui-native add aspect-ratio
Platforms: MAUI · Avalonia.
Usage
Basic
16 : 9
<ui:AspectRatio Ratio="1.7778" WidthRequest="360">
<Border StrokeThickness="0" StrokeShape="RoundRectangle 8" BackgroundColor="{DynamicResource ShellUIMuted}">
<Label Text="16 : 9" HorizontalOptions="Center" VerticalOptions="Center" />
</Border>
</ui:AspectRatio><ui:AspectRatio Ratio="1.7778" Width="360" CornerRadius="8">
<Panel Background="{DynamicResource ShellUIMutedBrush}">
<TextBlock Text="16 : 9" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Panel>
</ui:AspectRatio>Not available on yet
MAUI and Avalonia
- On Avalonia
AspectRatiois aBorder, soCornerRadiusrounds whatever is inside. - Set the width with
WidthRequeston MAUI andWidthon Avalonia.
API
| Property | Type | Default | Description |
|---|---|---|---|
Ratio |
double |
16 : 9 (1.7778) |
Width divided by height. 16:9 is 1.7778, 4:3 is 1.3333, a square is 1. |