双向DataGrid和阵列之间的结合 [英] Two way binding between DataGrid and an array

查看:139
本文介绍了双向DataGrid和阵列之间的结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个称为数组:

string[,] TableData;

可以使用绑定I连接其内容与DataGrid控件?

Can I link its content with a DataGrid control using binding?

如果有可能,我希望用户能够在阵列中编辑网格和反映这些变化。

If possible, I would like the user to be able to edit the Grid and reflect the changes in the array.

推荐答案

请参阅这个问题:<一href=\"http://stackoverflow.com/questions/276808/how-to-populate-a-wpf-grid-based-on-a-2-dimensional-array\">How填充基于2维阵列上一个WPF网格

您可以使用这种控制的名为 DataGrid2D 源$ C ​​$ C这里)。要使用它只需添加到DataGrid2DLibrary.dll的引用,添加这个命名空间

You can use this control called DataGrid2D (source code here). To use it just add a reference to DataGrid2DLibrary.dll, add this namespace

xmlns:dg2d="clr-namespace:DataGrid2DLibrary;assembly=DataGrid2DLibrary"

,然后创建一个DataGrid2D并将其绑定到你的IList,二维数组或一维数组像这样

and then create a DataGrid2D and bind it to your IList, 2D array or 1D array like this

<dg2d:DataGrid2D Name="dataGrid2D"
                 ItemsSource2D="{Binding Int2DList}"/>

用户将能够编辑在 DataGrid中所做的数据和更改将反映在二维数组

这篇关于双向DataGrid和阵列之间的结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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