开发者

Referencing ItemSource in code

开发者 https://www.devze.com 2023-02-19 20:21 出处:网络
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.

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>;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号