1

Possible Duplicate:
How to add or remove an item from a CollectionViewSource?

I have a datagrid that is bound to a CollectionViewSource . how can I add newItem to this source using code ?

Community
  • 1
  • 1
Mojtaba pirveisi
  • 81
  • 1
  • 2
  • 6

1 Answers1

1

I Just read the MSDN documentation. It says

You should not create objects of this class in your code. To create a collection view for a collection that only implements IEnumerable, create a CollectionViewSource object, add your collection to the Source property, and get the collection view from the View property.

So, I guess you should not be adding any items to a CollectionViewSource. Instead you should add items to the wrapping object.

Why do you need to do this anyway, what are you trying to achieve?

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
  • Ok . thanks . Source property of CollectionViewSource has bound to objectResult ( I am using entity framework . I executed ObjectQuery.Execute() and bound the result to CollectionViewSource.Source . now how can I Add new item to my source – Mojtaba pirveisi Sep 21 '12 at 17:21