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.
我ListBox有一些绑定的对象。每ListBox30 秒更新一次。更新后如何保持用户选择ListBoxItem?我ListBox使用该Clear()方法更新并再次设置对象。
ListBox
ListBoxItem
Clear()
嗯...如果你清除它...
object selection = myListBox.SelectedItem; myListBox.Clear(); myListBox.Items.AddRange(newItems); if (newItems.Contains(selection)) myListBox.SelectedItem = selection;