This is a migrated thread and some comments may be shown as answers.

CollectionEditor for ObservableCollection<int>

3 Answers 125 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 2
Martin asked on 31 May 2013, 01:04 PM
I am trying to get the CollectionEditor working for ObservableCollection<int>.
I am not able to add items. If I create a object with one int property I can add to the collection.

Is there a way to get it working with a list of int's?


3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 31 May 2013, 01:43 PM
Hi Martin,

The ability to insert an new item depends on:
1. Whether the source collection supports such functionality - to add/ insert a new element - this is supported by ObservableCollection
2. Business object should have default parameterless consturctor - which int element does not.
So, if you want to insert new items, you need to make sure that both conditions are satisfied.

Regards,
Maya
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Martin
Top achievements
Rank 2
answered on 31 May 2013, 02:04 PM
You can new a int like this: var x = new int();
But is it because int is a value type?
0
Maya
Telerik team
answered on 03 Jun 2013, 10:27 AM
Hi Martin,

The ability of the collection editor to insert new item corresponds to the property of the IEditableCollectionView - CanAddNew. Please check out this article for more information.

Regards,
Maya
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
Martin
Top achievements
Rank 2
Answers by
Maya
Telerik team
Martin
Top achievements
Rank 2
Share this question
or