Hi,
I have a Xam Forms App containing an Entry and a Listview.
I've tried to implement the MVVM design but somethings still puzzle me.
From what I understand, I will do the binding in the View(XAML) for the Listview datasource and data template.
However, I need the search terms to come from the Entry on Complete event, which will trigger a weather service to retrieve an ObservableCollection to be updated into the listview binding.
Currently, I'm doing it like this in the XAML Code Behind:
ObservableCollection<WeatherResultModel> resultList;
private async void Entry_Completed(object sender, EventArgs e)
{
string input = ((Entry)sender).Text;
if (input != null)
{
WeatherService weatherService = new WeatherService();
resultList = await weatherService.GetForecastByCityOrCountry(input);
SearchResultListView.ItemsSource = resultList;
}
}
How can I do this in a way that fits the MVVM paradigm?
Thanks!