为了制作一个聊天页面,我按照我发现的一个示例将 ListView 旋转设置为 180,因此列表从底部构建,然后将 DataTemplate 中的内容设置为旋转 180,因此项目将是直立的。这是一个很好的解决方案,但是当键盘打开时,ListView 会变短,从而导致重绘。在重绘期间,ListView 最初以旋转 0 出现,我看到一个动画,好像正在调用 RotateTo(360)。最初显示后,我可以看到列表视图绕了一圈旋转。单击消息编辑器,ListView 变得更高,它再次这样做。有人见过这个吗?
这是 Xaml 的样子。我无法制作它的外观,但想象一下:
MessageList.Rotation = 0;
MessageList.RotateTo(360, 500, Easing.Linear);
每次键盘显示和隐藏时,您都会明白...
<ListView
X:Name="MessageList"
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1"
Rotation="180"
ItemsSource="{Binding ChatMessages}"
SelectionMode="None"
HasUnevenRows="True"
SeparatorColor="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame
BackgroundColor="LightGray"
FlowDirection="LeftToRight"
Rotation="180"
Padding="10"
HasShadow="false"
Margin="80,2,0,5">
<Label Text="{Binding ChatText}"/>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>