I have a SL4 DataGrid whose ItemsSource is set to a StaticResource pointed to a ViewModel. I need to get the collection of data items from the DataGrid in a code-behind file. Since the ItemsSourc开发者_如何学编程e is an IEnumerable, I thought this would work, but it does not.
IEnumerable listEntities = DataGrid.ItemsSource as MyEntity;
I'm sure that I just have some simple construct wrong. Any help is appreciated.
Thanks.
Did you tried IEnumerable listEntities = DataGrid.ItemsSource as IEnumerable<MyEntity>;
精彩评论