I have collection of type Foo. It is bind to a RadGridView's ItemsSource. I want to get all current items from RadGridView using below code -
var current_collection = gv.Items.Cast<Foo>().ToArray();
I want to do the above dynamically using reflection, but having trouble making it run, below is my code so far -
var t = gv.ItemsSource.GetType().GetGenericArguments().Single();
Here t is Foo type.
var x = typeof(Enumerable).GetMethod("Cast").MakeGenericMethod(t).Invoke(gv.Items, null);
Aucun commentaire:
Enregistrer un commentaire