Monday, February 21, 2011

WPF ListBox insert

I have a WPF Listbox defined in a DataTemplate that has its ItemsSource bound to an ObservableCollection. When new items are added to the collection, I want the ListBox to work in "insert mode", always adding to the front of the list, not the default append mode. How do I make the ListBox use the insert mode when not adding to it directly in code?

From stackoverflow
  • Use the Insert method of the ObservableCollection and pass the index 0 - that will add it to the beginning of the collection.

0 comments:

Post a Comment