简体   繁体   English

我应该添加什么对象集合?

[英]What object collection should I have to add objects?

I'm using Prism in WPF. 我在WPF中使用Prism。

I was watching the Prism starter kit, and it has a ICollectionView. 我当时在看Prism入门工具包,它具有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. 您的列表应绑定到包装ObservableCollection的ICollectionView。 When you add, you add to this Observable collection. 添加时,您将添加到此Observable集合。

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 List2绑定到哪里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该如何抽象另一个对象拥有的对象集合? - How should I abstract a collection of objects owned by another object? 对象应该返回null,而对象集合应该返回空集合吗? - Should an object return null and a collection of objects return an empty collection? 如果您的接口带有对象集合,并且既需要该接口的只读版本又需要该接口的读写版本,该怎么办? - What should you do if you have an interface with a collection of objects and you want both a read-only and a read-write version of the interface? 父对象的集合成员的对象是否也应该引用父对象? - Should objects of a collection member of parent object also reference the parent object? 在这种情况下我应该使用什么集合? - What collection should I use in this case? 我应该使用什么类型的收藏? - What type of collection should I use? 在 WPF 中,我需要有一组绘图对象的集合 - in WPF I need to have a collection of a collection of drawing objects 如何将派生的 object 添加到从同一接口继承但使用 generics 的对象集合中? - How do I add a derived object to a collection of objects which inherit from the same interface, but use generics? 如何添加一个 int 级别变量来决定从哪个级别开始获取对象? 我应该向它们添加哪些对撞机? - How can I add a int level variable to decide from what level to start getting the objects? And what colliders should I add to them? 我有一个项目列表,并将其复制到集合中。 如果列表发生任何变化,它将自动反映在集合中 - I have a list of items and have copied it to a collection. If any changes happen to the list it should automatically reflect in the collection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM