I'm using the new Windows Phone 8 LongListSelector
control, which has its ItemsControl
assigned to a List<Group<object>>
as so:
List<Group<PlacePoint>> searchResults;
async void doSearch()
{
this.searchResults = await SearchHelper.Instance.getSearchResults(txtSearchTerm.Text);
longList.ItemsSource = this.searchResults;
}
Unfortunately, the second time that I search, re-setting the .ItemsSource property has no effect and the control simply displays the old List.
How can I change the binding?
Sometimes it helps to set the ItemsSource to null and then to your result right after.
It would seem that re-assigning longList.ItemsSource does not have any effect, whether this is a bug or by design I can't say.
However, an easy workaround is simply to use an ObservableCollection> instead and then work with this collection rather than re-assigning the ItemsSource.
Sample code:
You need to define your doSearch() method using async for await to function properly.
Try declaring you method like this: