ListBox, PollIterator and Transaction

Jul 22, 2008 at 12:22 PM

First of all, thanks for the brilliant library.

I have a trouble filling a WPF ListBox using the PollIterator.  The problem seems to be that once the events finaly start to be raised, the underling collection is already completely updated and hence not in sync with the sequentialy raised events.  This results in "Index was out of range." excpetion in BindableCollection.this[int index].  Also, the ListBox does not seem to support "range actions".

I have teporarly fixed the problems by not using transaction in the PollIterator, but I would like to know what the official solution is.

Could you also point me to a location explaining why the transactions are necessary in the first place?

Here is the code I use for the reference:

public partial class Window1 : Window
    List<string> items = new List<string>();

    public Window1()
        listBox.ItemsSource = items.AsBindable().Polling(this.Dispatcher, TimeSpan.FromSeconds(1.0));

    private void Button_Click(object sender, RoutedEventArgs e)
        // These two result in "Index was out of range." excpetion in
        // BindableCollection.this[int index]
        // Uncomenting this will also result in "Range actions are not supported."
        // excpetion in ListCollectionView
        // items.Add("four");