为什么我不能将WPFToolkit DataGrid ItemSource绑定到DataTable? [英] Why can't I bind the WPFToolkit DataGrid ItemSource to DataTable?

查看:234
本文介绍了为什么我不能将WPFToolkit DataGrid ItemSource绑定到DataTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Telerik 控件中,我可以将 DataTable 直接绑定到 ItemSource ,但是当我切换到Codeplex WPFToolkit Datagrid

In a Telerik control, I was able to bind a DataTable directly to the ItemSource, but when I switched to the Codeplex WPFToolkit Datagrid:

<dg:DataGrid Name="theGrid"/>
---
theGrid.ItemsSource = dt;

我收到此错误:

Cannot implicitly convert type 'System.Data.DataTable' to 'System.Collections.IEnumerable'.

如何将 DataTable 绑定到 WPFToolkit DataGrid

推荐答案

您必须将您的datatable投影到实现IEnumerable的东西,就像DataGrid所期待的那样。该网格是与Telerik版本不同的实现,因此很难期待两者的相同功能。

You'll have to project your datatable into something that implements IEnumerable as that is waht the DataGrid expects. The grid is a different implementation to the Telerik version so its hard to expect the same functionality from both.

这篇关于为什么我不能将WPFToolkit DataGrid ItemSource绑定到DataTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆