Unanswered ObservableVector not raising event

  • Friday, November 11, 2011 3:37 AM
     
      Has Code

    I know about the problems with databindng to an ObservableCollection and am using ObservableVector from the SDK sample.  I'm seeing really weird behavior in my app though - when the collection changes, the VectorChanged event doesn't get raised.  Confused by this, I dropped a breakpoint in the Add method:

            public void Add(T item)
            {
                _internalCollection.Add(item);
                
                if (VectorChanged != null)
                {
                    VectorChanged(this, new VectorChangedEventArgs { CollectionChange = CollectionChange.ItemInserted, Index = (uint)(_internalCollection.Count - 1) });
                }
            }
    


    If I set a watch on VectorChanged it shows "{System.Runtime.InteropServices.WindowsRuntime.EventRegistrationTokenTable<Windows.Foundation.Collections.VectorChangedEventHandler<Windows.UI.Xaml.Media.Imaging.BitmapSource>>}" which I assume means that the binding is trying to work.  Likewise, if I set a watch on "VectorChanged!=null" it shows "true". 

    But very strangely, when I step through this code line by line execution jumps straight over the if-block so the event never gets raised.

    Any ideas?


    Robert Levy

All Replies

  • Friday, November 11, 2011 11:30 AM
     
     

    While you're in debug press (+) left to "{System.Runtime.InteropServices.WindowsRuntime...........Imaging.BitmapSource>>}"

    And look for a subscribers count.

    It should be 0 in your case (so noone have allready beed subscribed for notifications)


    Kind regards, HeToC. http://www.linkedin.com/in/hetoc
  • Sunday, November 13, 2011 10:10 AM
     
     

    ps: this is a known issue when you're binding JumpView's base ItemsSource in XAML.


    Kind regards, HeToC. http://www.linkedin.com/in/hetoc