I have a mobileList<> of Root objects as ItemSource of an AutoCompleteBox. I allow the user to Add/Remove items to the list. Everything works great except for one thing.
In the ViewModel, I have these methods
public void AddCityToCityList(string city)
{
if (city.Length > 0)
{
City obj= City.NewCity(city);
obj.BeginSave(SaveComplete);
}
}
private void SaveComplete(object sender, SavedEventArgs e)
{
this.Model.Add((City)e.NewObject);
}
I know that the city is added to the list, but it does not show up in the AutoCompleteBox list unless I reload the CityList by by doing this:
this.Model.Add((City)e.NewObject);
BeginRefresh("GetCityList");
which makes this line: this.Model.Add((City)e.NewObject); pretty much redundent.
Some of my lists are pretty large. I would love to have the AutoCompleteBox list get updated with the ListChanged event when I Add/Remove the items - but I cannot figure out how.
Jav
In your Add method on the model, can you raise a NotifiyCollectionChanged event? I don't believe MobileList implements the INotifyCollectionChanged interface. May need to make a subclass that will.
I believe Csla Collection classes inherit from BindingList<T> and therefore implement IBindingList interface which supports ListChanged Event. Based on that, one can say that Csla collection classes do not implement INotifyCollectionChanged. But I would assume that ListChanged event is being raised by the MobileList as an item is either added or removed. Is the AutocompleteBox (Or a ListBox or DataGrid) not supposed to respond to it by refreshing the ItemSource. Or is there something I am supposed to do?
Jav
Copyright (c) Marimer LLC