wpf - 为什么我无法将 WPF Toolkit DataGrid ItemSsource 绑定(bind)到 DataTable?

标签 wpf data-binding datagrid telerik wpftoolkit

Telerik 控件中,我能够将 DataTable 直接绑定(bind)到 ItemSource,但是当我切换到 Codeplex WPFToolkit 数据网格:

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

我收到此错误:

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

如何将DataTable绑定(bind)到WPFToolkit DataGrid

最佳答案

我发现最简单的方法是:

myDataGrid.ItemsSource = myDataTable.DefaultView;

因为DefaultView实现了IEnumerable

关于wpf - 为什么我无法将 WPF Toolkit DataGrid ItemSsource 绑定(bind)到 DataTable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/502667/

相关文章:

wpf - EF5 和 DB2 9.1。 bool 未定义类型错误

wpf - Silverlight/WPF 和 Blend : DataBind a text field, 但定义设计时值?

android - Webview 和 ProgressBar 的 2 种方式数据绑定(bind)

wpf - 将样式资源分配给 DataGrid

c# - 与 ElementName 绑定(bind)不适用于 WPF TabItem 内的动态构造控件

c# - 如何在 WPF 中获取与桌面相关的鼠标位置?

c# - WPF DatePicker 选择不正确的日期

string - 删除字符串的内容 - TextBox 的行为与 DataGridView 文本单元格略有不同

WPF DataGrid 多选绑定(bind)

c# - 使用绑定(bind)禁用特定的 DataGrid 单元格