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.
我在 DataTemplate 中定义了一个 WPF 列表框,它的 ItemsSource 绑定到 ObservableCollection。当新项目添加到集合中时,我希望 ListBox 在“插入模式”下工作,始终添加到列表的前面,而不是默认的附加模式。不直接在代码中添加列表框时,如何使列表框使用插入模式?
使用 theInsert方法ObservableCollection并传递索引 0 - 这会将其添加到集合的开头。
Insert
ObservableCollection