Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit AutoComplete UI not reflecting ObservableCollection<T>.Clear() - Silverlight 3
2 replies. Latest Post by jwilcox on June 30, 2009.
(0)
Zack123
Member
4 points
4 Posts
06-30-2009 11:28 AM |
Hi,
I have an AutoComplete control that works great, other than the fact that the ObservableCollection<T>.Clear() method does not alter the ItemsSource. So when I offset my filtering and searching to the server, the results just keep being added to the list. Is there anything I can do to get around this? I have also repproduced this is a simple test application.
Any help is greatly appreciated.
Zack
public
{
public MainPage()
InitializeComponent();
TestOBVC = new ObservableCollection<People>();
TestOBVC.Add(new People() { FirstName = "John", LastName = "Smith" });
TestOBVC.Add(new People() { FirstName = "John", LastName = "Smithe" });
TestOBVC.Add(new People() { FirstName = "John", LastName = "Smithers" });
TestOBVC.Add(new People() { FirstName = "John", LastName = "Schimdt" });
this.TestAutoSelector.ItemsSource = TestOBVC;
this.TestAutoSelector.ItemFilter = ((search, item) =>
People person = item as People;
if (person != null)
string filter = search.ToLower();
return (person.FirstName.ToLower().Contains(filter) ||
person.LastName.ToLower().Contains(filter));
}
return false;
});
private void Button_Click(object sender, RoutedEventArgs e)
TestOBVC.Clear();
public ObservableCollection<People> TestOBVC { get; set; }
public class People
public People()
public string FirstName { get; set; }
public string LastName { get; set; }
------------------------------------------And the Xaml -------------------------------------
</
bartczer...
Contributor
4172 points
730 Posts
06-30-2009 1:17 PM |
On the click event you can set the ItemSource to null and then back to the collection.
jwilcox
Participant
1082 points
187 Posts
06-30-2009 2:36 PM |
We actually made some changes to the internal handling of the Reset collection notification event, so in the next Silverlight 3 SDK release (and Silverlight 2 Toolkit release) this should be fixed.