This project is read-only.

Overlaying issue when bound to ObservableCollection


I hate to double post but this is an issue....
I'm using RIA Services to load images from a database, now I have an ObservableCollection bound to the ItemSource and whenever a new entry is added, it is overlayed on the previous, instead of stacking the item to the right.


lukesandberg wrote Sep 28, 2009 at 3:52 PM

I believe i know what the problem is here. when new items are added or removed they are correctly added to the items list, but the layout is not properly updated. I fixed this issue (partially) in the copy i dowloaded by adding an override to the OnItemsChanged method:

protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        if (SelectedIndex > items.Count) SelectedIndex = items.Count - 1;
Also there is the occasional issue (im not sure why where there is a CoverFlowItemControl in the items array which has not been templated yet. this causes some issues so i also added a simple check to CoverFlowItemControl.SetValues:

public void SetValues(double x, int zIndex, double r, double z, double s, Duration d, IEasingFunction ease, bool useAnimation)
        if (!HasAppliedTemplate) return;

This seems to be working for me, I hope it works for you.

wrote Feb 14, 2013 at 7:10 PM