I am using mvvmcross (with great fun) but I keep having problems with adding and removing items from mvxlistview:
My View is binded to a List of items which are retrieved from a web server so it is done in a different thread:
async void ActivateSearchInvoked ()
{
_activeSearchViewModel.IsLoading = true;
await _activeSearchViewModel.Search (SearchString);
_activeSearchViewModel.IsLoading = false;
}
Search is a method which calls InnerSearch, Here is the code in the View Model
protected override Task InnerSearch ()
{
Users.Clear ();
return Task.Factory.StartNew (SearchForUsers);
}
protected virtual void SearchForUsers()
{
int requestringUserID = AppConfiguration.Instance.User.ID;
List<User> users = GetUsersFromWeb();
if(users == null)
{
return;
}
foreach (var item in users)
{
Users.Add (new UserViewModel (item));
}
RaisePropertyChanged (() => Users);
}
This does not seem to work properly until the screen is refreshed (for instance rotating it) Am I missing something?
Thanks
Amit