为什么自动完成工具包没有更新新项目?

why AutoComplete toolkit not updated with new items?

我将 toolkit:AutoCompleteBox 的数据源设置为字符串项列表。它工作正常但是当我想添加一个新项目到列表然后再次将列表设置为 toolkit:AutoCompleteBox 的数据源时,它不会被添加。 我认为 toolkit:AutoCompleteBox 的数据源未更新。

您知道如何添加新项目吗?或刷新或更新列表?

List<string> c1 = new List<string>();
//... add some items to c1
txt11.ItemsSource = c1;
c1.Add(txt11.Text.Trim());
txt11.ItemsSource = c1;

天啊,我发现这段代码很容易出问题: 我必须再次分配。第一次给 AutoCompleteBox 赋 null。

List<string> c1 = new List<string>();
//... add some items to c1
txt11.ItemsSource = c1;
c1.Add(txt11.Text.Trim());
txt11.ItemsSource = null; 
txt11.ItemsSource = c1;