且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

DataGrid 和数组之间的两种方式绑定

更新时间:2023-02-27 07:43:19

看到这个问题:如何基于二维数组填充WPF网格

您可以使用这个控件,名为DataGrid2D(源代码在此).要使用它,只需添加对 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中所做的更改将反映在二维数组中

The users will be able to edit the data and changes made in the DataGrid will be reflected in the 2D Array