如何在ListView的TextCell中包装文字?

nic*_*cks 2 listview xamarin xamarin.forms

如何在ListView的TextCell中包装文字?我尝试设置HasUnevenRows为,True但这无济于事。

Jac*_*ley 7

您无法使用Xamarin的“开箱即用” TextCell功能。但是,您应该能够创建ViewCell并利用Label 的LineBreakMode属性完成自动换行。大概是这样的:

<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>
Run Code Online (Sandbox Code Playgroud)