jeudi 30 juillet 2015

Getting the type of the object inside List inside ItemsSource

I have a DataGrid that is given a List, which can be either of type Foo, Bar, or Baz. Later on, I need to extract that data to save it, and to do so I need to know the type of the object inside the List that was set as ItemsSource. I have tried to use GetType, didn't work, trying to do if(GridType is List<Foo>) for example produces the following warning:

The given expression is never of the provided ('System.Collections.Generic.List<Foo>') type

And I couldn't find anything on this error. Searched SO too, couldn't find anything. Is there a way to do what I am trying to do? Or even, a better way than simply getting the type directly?





Aucun commentaire:

Enregistrer un commentaire