Grid will not expand vertically to fit content

What I am trying to do is have a 2 column grid inside a listview to show my search results. I cannot get the row to fit the content vertically unless I specifically supply a RowHeight in the XAML. I tried simplifying the grid. Even putting everything in a stacklayout as shown below. All that happens is I can read the bound value from f1. Everything else gets cropped out. Ideally just looking to use the Grid without the inner StackLayout, I only tried it hoping it would work.

What am I missing???

I am testing this on Android.

<ContentPage.Content>
    <StackLayout>
        <StackLayout>
            <Label x:Name="NewMatchHeader" FontSize="18" TextColor="Black" FontAttributes="Bold" Text="{Binding MatchCount}" />
        </StackLayout>
        <StackLayout VerticalOptions="FillAndExpand">
            <ListView x:Name="NewMatchesView"
                  ItemsSource="{Binding Results}"
                  SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                  SeparatorColor="#CCCCCC"
                  BackgroundColor="#FFFFFF">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />

                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>

                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <StackLayout Grid.Column="0" Grid.Row="0" Orientation="Vertical" VerticalOptions="StartAndExpand">
                                    <Label Text="{Binding f1}" FontSize="32" FontAttributes="Bold" TextColor="{StaticResource highlightColor}"/>
                                    <Label Text="{Binding f2}" TextColor="#999999"  FontSize="14" />
                                    <Label Text="{Binding f3}" TextColor="#999999" FontSize="12"/>
                                    <Label Text="{Binding f4}" TextColor="#999999"  FontSize="12"/>
                                </StackLayout>

                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </StackLayout>
</ContentPage.Content>
Tagged:

Best Answer

Answers

  • elpresidente408elpresidente408 Member ✭✭

    I can't believe it was that simple...haha. That fixed it.

Sign In or Register to comment.