I got exception :
Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
I got exception : Operation is not valid while ItemsSource is in use. Access
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You must add the items to your source-collection that is set to
ItemsSource. After you have set theItemsSource-property to a value, its no more possible to use theItems-property (besides you setItemsSourcenewly to null).ItemsandItemsSourceexclude each other.If you use
ItemsSource, your source-collection must implementINotifyCollectionChangedso that it will inform theListViewabout changes. If not, added items to it will not change theListView. E.g. if you useList<T>as items-source, changes will not be forwarded.There exist classes that do that for you such as
ObservableCollection<T>.