I am creation an Xamarin foms app where I will have messages coming over time, and I always want the new messages to show on the button of my ListView as they are coming in.
At the moment my page looks like this:
<StackLayout>
<Button Text="Login" />
<ListView x:Name="MessageBox" ItemsSource="{Binding TempTest}" ></ListView>
<Button Command="{Binding AddMessage}" Text="Login"/>
</StackLayout>
I cant figure out how to scroll from my ViewModel class, any ideas about how to achieve this?
The best that I have been able to find so far are this: http://www.infinite-x.net/2014/10/30/using-the-xamarin-forms-1-3-0-listview-scrollto-method/
But he is not even thinking about using MVVM at this stage.
Well the one, less than elegant way, I would know to solve that would be to expose an
Action<Message>
from your ViewModel and then yourContentPage
would initialize thatAction
and tell it to do the scrolling. Something like the following (just replaceMessage
with what ever the real model name is).ContentPage:
ViewModel: