CollectionEditor for ObservableCollection<int>

4 posts, 0 answers
  1. Martin
    Martin avatar
    39 posts
    Member since:
    Sep 2008

    Posted 31 May 2013 Link to this post

    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?


  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 31 May 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Martin avatar
    39 posts
    Member since:
    Sep 2008

    Posted 31 May 2013 Link to this post

    You can new a int like this: var x = new int();
    But is it because int is a value type?
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Jun 2013 Link to this post

    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.

Back to Top