简体   繁体   中英

What object collection should I have to add objects?

I'm using Prism in WPF.

I was watching the Prism starter kit, and it has a ICollectionView. In that collection, I need to add the object selected in it. What object (or collection) should I use to add objects?

在此处输入图片说明

I mean in the image, I have two listbox, in the first one I've got a readonly collection and the second one is a list where can add or remove objects.

Your List should be bound to an ICollectionView that wraps an ObservableCollection. When you add, you add to this Observable collection.

Ie

private readonly ObservableCollection<Stock> listToAddTo;

public ICollectionView List2 { get; private set; }

Constructor

  listToAddTo = new ObservableCollection<Stock>();
  List2 = CollectionViewSource.GetDefaultView(listToAddTo);

Where List2 is what is bound to

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM