开发者

Adding new item to pageCollection's object

开发者 https://www.devze.com 2023-01-22 13:14 出处:网络
i am working with an pageCollectionin silverlight ,i have some remove and addition work into the pagedviewcollection\'sobject

i am working with an pageCollectionin silverlight ,i have some remove and addition work in to the pagedviewcollection's object

i was able to remove from collection as below

_pageCollection.RemoveAt(_index);

but i am not able add an item to the pageCollection .how to add an item to the _pageCollection. i feel it should be dealt with below code

_pageCollection.AddNe开发者_运维百科w();

but i amnot able to get how to proceed?


If you use a PagedCollectionView you have to set a source IEnumerable. If you add it to this collection it will work (assuming that your PCV is working with a list of Products which have an id).

myPagedCollectionView = new PagedCollectionView(myCollection);
myCollection.Add(new Product(){Id=5});

If you work with AddNew you have to do it like this :

var obj = (Product)myPagedCollectionView.AddNew();

obj.Id = 5;

Hope this is what you needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消