Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4047404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:41:11+00:00 2026-05-20T13:41:11+00:00

A control has an ItemsSource Property of type IEnumerable. If I try to add

  • 0

A control has an ItemsSource Property of type IEnumerable. If I try to add items to Items collection when ItemsSource is set I get an error “Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.”

A method for Removing Items is present here:
WPF – Best way to remove an item from the ItemsSource

However I cannot find a method to (based on the same interface) to add a new Item. The AddNew method does not take any arguments. From the sample at : http://msdn.microsoft.com/en-us/library/system.componentmodel.ieditablecollectionview.canaddnew.aspx I felt this to be the correct code:


IEditableCollectionView items = paneToDropInto.Items;
                if (items.CanAddNew)
                {
                    object newitem = items.AddNew();
                    newitem = contentToTransfer;
                    items.CommitNew();                    
                }

However it does not work. It does add the new item. But it is a blank Item. Note contentToTransfer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:41:11+00:00Added an answer on May 20, 2026 at 1:41 pm

    Figured it out. As pointed out by Tom and Djerry +1 both (thanks). I am just re referencing the new item which will not cause the original new item generated by AddNew to be saved (very stupid of me).

    However there is another interface I can use (and did use):

    
    IEditableCollectionViewAddNewItem items = paneToDropInto.Items;
    if (items.CanAddNewItem)
    {
        object newitem = items.AddNewItem(contentToTransfer);                    
    }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So the Rectangle control has RadiusX and RadiusY property for making rounded corners. However,
I have a wpf control named DataPicker which has a dependency property named SelectedDate.
First, my scenario. I have a ViewModel with a public property Items of type
Hi I have a tab control which is bound to a collection property of
If the ItemSource property of a combo box has been set, why could clicking
DockingManager control has been removed from their suite in Q1 2011, so now I
I want my list control has its content height as I don't want scroll
It seems to me that the Ribbon control has a problem with textboxes. I
I am adding a user control dynamically on a page, the user control has
I have a custom user control on my windows forms. This control has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.