Hi there
I can't get the AutoComplete control to update it's ItemsSource via data binding. Everything appears to go smoothly... I use the OnPropertyChanged event to update the ObservableCollection<string> in the model, and then call RaisePropertyChanged("SearchResults"), but nothing happens client side. It's still attached to the original list of test items I started with. I don't replace the ObservableCollection, I'm clearing it and then added the new values. If I try to replace the collection, the application crashes.
xaml
<input:RadAutoComplete
x:Name="AutoCompleteAddress"
Watermark="Search here..."
ItemsSource="{ Binding SearchResults }"
PropertyChanged="AutoCompleteAddress_OnPropertyChanged"
CompletionMode="Contains"/>
Code Behind
private void AutoCompleteAddress_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Text")
{
var addressDetailsPageModel = (AddressDetailsPageModel)BindingContext;
addressDetailsPageModel.SearchAddress(AutoCompleteAddress.Text.Trim());
}
}
Page Model
public async void SearchAddress(string searchText)
{
var searchResults = await _addressSearchService.SearchAsync(searchText);
SearchResults.Clear();
foreach (var searchResult in searchResults)
SearchResults.Add(searchResult);
RaisePropertyChanged("SearchResults");
}
public ObservableCollection<string> SearchResults { get; set; }
Any ideas?
Cheers