Conversion c# wpf Icollection and Observablecollection

Asked

Viewed 35 times

1

I have a list Icollection Generica and need to convert to Observablecollection, so I do not know which class is to convert to

ObservableCollection<MyClass>.

I’ve been searching for that answer for a few days now, is that possible? how would I?

1 answer

1

You can use the constructor that receives a Ienumerable as a parameter and pass your collection to convert.

Would look like this:

ICollection<MyClass> listaCollection = new List<MyClass>();

ObservableCollection<MyClass> observableCollection = new ObservableCollection<MyClass>(listaCollection);

Here is the documentation on the builders of this class: here

  • but in case, I don’t know what class it is, so there’s no way I can create it like you created it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.