Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

[c# / WPF] How to remove items from collection view source without error ?

$
0
0

Hi,

I have a simple database app (EF) that will show some entries in a combobox. I've created datasources from my entities, and bound the combobox to the view source collection via the ItemsSource property.

Added functionality for adding and deleting items. Adding is working fine, the combobox gets updated with the new entry.

But when I try to delete, I get an error:

"System.NullReferenceException" error when deleting item from collection view source

and: Object reference not set to an instance of an object.

I've figured this happens because when I remove an item from _recipes (the ObservableCollection that is linked to the CollectionViewSource), the entry gets set to null, and ComboBox won't accept the null value in the list?

Anyway, the error pops up when I get to the statement: _recipes.Remove((Recipes)forDeletion);

Does anyone understand my question, lol?

can anybody help me?


Viewing all articles
Browse latest Browse all 18858

Trending Articles