【发布时间】:2017-08-23 19:34:01
【问题描述】:
我使用 Xamarin.Forms(MVVM 设计模式)开发了一个聊天应用程序。 我需要在发送消息后自动向下滚动 ListView(聊天消息列表)。
我的观点:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
...>
<ContentPage.Content>
<StackLayout Style="{StaticResource MainLayoutStyle}">
...
<Frame
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
CornerRadius="5"
BackgroundColor="White"
Padding="5">
<ScrollView>
<StackLayout>
<ListView
x:Name="MainScreenMessagesListView"
ItemTemplate="{StaticResource MessageTemplateSelector}"
HasUnevenRows="True"
BackgroundColor="#e5ddd5"
ItemsSource="{Binding Messages}">
</ListView>
</StackLayout>
</ScrollView>
</Frame>
...
</StackLayout>
</ContentPage.Content>
由于我的设计模式,我不能使用 ScrollTo 方法(对吗?) 并且 xaml 中没有 ScrollTo 属性。
那么这个问题有什么解决办法呢?
谢谢!
【问题讨论】:
标签: listview mvvm xamarin.forms