2015-03-02 24 views
-2

我將工具包的數據源:AutoCompleteBox設置爲字符串項目列表。它工作良好,但是當我想要添加一個新的項目列表然後再次設置工具箱的數據源的列表:AutoCompleteBox,它不會被添加。 我覺得工具包的數據源:AutoCompleteBox沒有更新。爲什麼AutoComplete工具包未更新新項目?

你有什麼想法如何添加一個新的項目?或刷新或更新列表?

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

回答

1

噢,我的上帝,我發現問題容易驗證碼: 我不得不再次分配。第一次給null AutoCompleteBox。

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;