Luis
Luis

Reputation: 31

Xaml Grid Column Width Auto is ignored by all platforms except UWP

<Grid.ColumnDefinitions>
   <ColumnDefinition Width="Auto"/>
   <ColumnDefinition/>
</Grid.ColumnDefinitions>

in UWP the above results in the first column to horizontally expand just enough to fit the contents but second column grows to take the rest of the available width on the device screen. in iOS / Android / Wasm the first column expands to take the whole screen - I never get to see the second column. I believe the second column may still be there but squashed or pushed outside of the screen.

The workaround for me was to set the column widths explicitly by for example saying first column is 30* and forth column is 70*.This also works and correctly shows the 2 columns:

<Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="leftCol" Width="110"/>
            <ColumnDefinition x:Name="rightCol" Width="*"/>
</Grid.ColumnDefinitions>

Upvotes: 3

Views: 159

Answers (1)

David Oliver
David Oliver

Reputation: 2321

In general Grid.Auto is supported by Uno on iOS/Android/WASM. The code below works as expected, for example.

If you're seeing an issue, it's probably related to the content of the Grid. If you're able to post some code that reproduces the issue, we can help you further.

<Grid Margin="0,100,0,0">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <TextBlock Text="In auto"
               Grid.Column="0" />
    <Border Background="Pink"
            Height="50"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Top"
            Grid.Column="1"/>
</Grid>

Windows:

Grid.Auto Windows

iOS:

enter image description here

Upvotes: 3

Related Questions