Home Forums WPF controls Xceed DataGrid for WPF GridView doesn’t update for List<Person> type?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23851 |

    e.g.

    List<Person> people = new List<Person>();
    people.Add(new Person() { Name = “Matt” });

    myXceedGrid.ItemSource = people;

    // AT THIS POINT GRID SHOW ONE ITEM AS EXPCETED

    Thread.Sleep(5000);

    people.Add(new Person() { Name=”Fred” });

    // STILL SHOWS ONE ITEM

    The grid doesnt display the second item until I sort a column..

    Is this intention?

    Imported from legacy forums. Posted by MattCheshire (had 498 views)

    Xceed Support
    Member
    Post count: 5658

    The List<T> class does not implement change notification… Therefore, it is normal that the grid does not update…

    The datasource needs to implement either IBindingList or INotifyCollectionChanged for the change notification to function…

    One quick way is to use the ObservableCollection<T> class instead of List<T>.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 253 views)

    User (Old forums)
    Member
    Post count: 23064

    So, I had a scenario wherein I was updating my ObservableCollection class’s underlying List rather than calling Add on the observable list itself ( I had a filesystemwatcher calling a callback in my observable collection that did somethings, and then altered the List, but since it had direct access and wasn’t using the add and remove methods… the datagrid was not getting events)

    Imported from legacy forums. Posted by Michael (had 3452 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.