Alexander
Alexander

Reputation: 17

Why does Listview hide text too long?

Listview hides long text.

Visual Studio, Xamarin-Forms

ListView x:Name="listView" Refreshing="Refresh">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Margin="20,0,0,0" HorizontalOptions="FillAndExpand" Orientation="Horizontal">
<Label Text="Text and text"  FontAttributes="Bold" VerticalTextAlignment="Start" HorizontalOptions="StartAndExpand" />
<Label Text="Text text text text Text text text textText text text textText text text textText text text textText text text textText text text textText text text textText text text text " />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
</ListView>

The only way out that I found is RowHeight = 70 But I do not like RowHeight = 70, because everywhere the text is of different length

Upvotes: 0

Views: 167

Answers (1)

VenkyDhana
VenkyDhana

Reputation: 905

You need to set HasUnevenRows property to True and let unset the RowHeight property. Also set LineBreakMode for Label

<ListView ItemsSource="{Binding List}" HasUnevenRows="True" SeparatorVisibility="None">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Grid>
                   <Label LineBreakMode="WordWrap"/>
                </Grid>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Upvotes: 1

Related Questions