WPF的Datagrid绑定错误在列标题点 [英] WPF Datagrid binding errors with dots in column headers

查看:129
本文介绍了WPF的Datagrid绑定错误在列标题点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我使用的源到数据网格WPF一个.net数据表。我的问题是,一些在数据表列标题包含点。当数据表绑定到DataGrid,将显示含有点列,但不包含任何数据。

I have a .Net datatable that I am using as a source to a WPF datagrid. The problem I have is that some of the column headers in the datatable contain dots. When binding the datatable to the datagrid, the columns containing dots are displayed, but contain no data.

在网上我已经做了,该点是数据绑定引擎内使用一个特殊的符号和混淆DataGrid的绑定表中读取后,周围。

After reading around on the net I have worked out that the dots are a special notation used within the databinding engine and are confusing the datagrid's binding to the table.

我曾尝试手动创建DataGrid列+绑定并添加方括号否定点。这工作得很好,但后来当我列排序打破。 本文提到挂钩到排序事件中删除[ ]在排序的事件。有wasnt如何实现这么多的细节,我似乎没有尝试并没有摆脱错误的。

I have tried manually creating the datagrid columns + bindings and adding square brackets to negate the dots. This works fine but then breaks when I sort a column. This article mentions hooking into the sorting event to remove the [] on the sorting event. There wasnt much detail of how to achieve this and what I did try did not seem to get rid of the error.

请让我知道如果您需要了信息。

Please let me know if you require anymore information.

推荐答案

正如你已经发现,超过之外的任何绑定点符号是WPF问题。什么我建议是修改你的头,以用别名点符号列名:

As you've discovered, dot notation for anything other than Binding is problematic with WPF. What I'd recommend is to revise your headers to alias the column names with dot notation:

Col.A should be Col_A
Col.B should be Col_B
etc...

如果标题是直接使用SQL查询来,别名以同样的方式在SQL列名。

If the headers are coming from a direct SQL query, alias the sql column names in the same manner.

下乡使用点符号的路径将只是继续领先于一体的hackish修复程序解决以前的'修复'。所有这一切都可以通过只修改您的命名约定可以轻松解决。

Going down the path of using the dot notation will just continue leading into one hackish fix to resolve the previous 'fix'. All of this can be easily resolved by just revising your naming conventions.

这篇关于WPF的Datagrid绑定错误在列标题点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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