Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap text in ListView's TextCell?

How to wrap text in ListView's TextCell? I tried setting HasUnevenRows to True but that didn't help.

like image 453
nicks Avatar asked Jan 06 '23 14:01

nicks


1 Answers

You cannot with Xamarin's 'out-of-the-box' TextCell features. BUT, you should be able to create a ViewCell and leverage the LineBreakMode property of Label to accomplish word wrapping. Something like this perhaps:

<ListView>
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout>
                    <Label Text="My TextCell Text" LineBreakMode="WordWrap"/>
                    <Label Text="My TextCell Detail" LineBreakMode="WordWrap"/>
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>
like image 143
Jacob Shanley Avatar answered Jan 10 '23 11:01

Jacob Shanley