Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Problem displaying the right data
posted

Hi guys,

Was needing auto filter implemented and I went and created a class to inherit ICollectionView, INotifyPropertyChange and INotifyCollectionChange. My class takes an IList<INotifyPropertyChange> as the source collection so that whenever one of the underlying collection elements has one of its fields changed, the collectionview will test if it matches the filter( the collection view class takes a PropertyDescriptor and a value as a filer; the propertydescriptor is related to the type of the object in my underlying collection)
Went on and bound the grid to this collection I realised the grid displays sometimes items that are not matching my criteria. My unit tests point out the collectionview correctly identifies the subset of the source collection matching the filter and it correctly raises the right collection change events. I have a
class MyItem : INotifyPropertyChange
{
     public int FieldA
     {
          get
          {
          }
          set
          {
             //if value has changed raise the event
          }
     }
}

and an ObservableCollection<MyItem> as the source collection of my collectionview. My observablecollection has just two items in it. On a timer I am changing this FieldA value with one
in a range from 0 to 5. I have set the value for my auto filtering to 3-let's say, and here is where it gets interesting and wrong. Whenever first item in the underlying collection gets its FieldA set up to 3
it correctly appears on the screen; whenever the second item gets its FieldA set up to 3 - I get an entry on the grid(as I have one item matching my criteria) but the problem is
it is displaying the value from the first item. so it looks like my row is actually linked to the first item in my underlyingcollection and I think this is because the row was on the initial load bound to this item.

I have changed the RecordContainerGenerationMode  from recycling to all the other ones thinking that since is reusing the controls it is still bound to the initial data..it didn't make any difference though.

Is this something you can look into and advise? as the problem is a show stopper Smile

 

Thanks,
  Stefan