Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这一定很简单,我看不到。如何阅读自动完成框中所选项目的文本?
当我输入“Mi”并且“Milk”在下拉列表中完成时,“Mi”仍将是 autocomplete.text 中的值的文本,尽管“Mi”在文本框中视觉上被替换为“Milk”?
使用 selectionchanged 事件来获取所选项目。您可以更新自动完成控件的文本以反映所选项目。
private void SearchBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { string selecteditem = (string)e.AddedItems[0]; this.SearchBox.Text = selecteditem; } }