0
votes

I'm trying to get an Entry field to fill a ListView row on Xamarin.Forms but everything I try just leaves the Entry field with the length of the placeholder.

I've tried HorizontalOptions with "Start and Expand" on almost every part of the hierarchy and it still remains at the shortest length required by the placeholder.

If I don't put this within a ListView and instead place it in a regular StackLayout then it fills without any problem.

The following XAML is designed to show an Icon on the left and then the text entry field to the right, filling to the end of the row.

What am I missing?

 <ContentPage.Content>
            <ListView IsGroupingEnabled="True" GroupDisplayBinding="{Binding Title}" SeparatorVisibility="None" HasUnevenRows="True" Margin="10,5,10,0"  >
                <ListView.ItemTemplate>
                    <DataTemplate >
                    <ViewCell >
                        <StackLayout Orientation="Horizontal" Padding="5" HorizontalOptions="StartAndExpand">
                            <Image Source="{Binding ImageURL}" HeightRequest="30" WidthRequest="30"/>
                            <Entry Text="{Binding Input}" Placeholder="{Binding Name}" HorizontalOptions="StartAndExpand"/>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
</ContentPage.Content>
1

1 Answers

1
votes

I don't test it, but you can try setting the HorizontalOptions=FillAndExpand in ListView, StackLayout and Entry

<ContentPage.Content> <ListView IsGroupingEnabled="True" GroupDisplayBinding="{Binding Title}" SeparatorVisibility="None" HasUnevenRows="True" Margin="10,5,10,0" HorizontalOptions="FillAndExpand"> <ListView.ItemTemplate> <DataTemplate > <ViewCell > <StackLayout Orientation="Horizontal" Padding="5" HorizontalOptions="FillAndExpand"> <Image Source="{Binding ImageURL}" HeightRequest="30" WidthRequest="30"/> <Entry Text="{Binding Input}" Placeholder="{Binding Name}" HorizontalOptions="FillAndExpand"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </ContentPage.Content>