I have a listbox with datatemplate, with 2 textblocks which binding some properties of some class,i have a list with elements of type of that class,i want to dynamically show this elements i.e at first show first 20 elements, than next 20 and etc, but how can I do that, to itemsource I can only assign a list, I can't add elements to it dynamically, please help me.
In order for a ListBox
to update dynamically as items are added to the list, you need to choose a collection class that raises events when items are added / removed. You should use ObservableCollection
as your ItemsSource
. This collection raises the CollectionChanged
event when it is modified. ListBox
handles this event and updates accordingly.