How to implement custom data binding to DataGrid in WPF?

There is a class which contains List<byte[][]></byte[][]> property, where the list item is the read from the file element (element array of fields, each of which contains the value in the byte array, the number of fields for all elements equally), in the form of a two-dimensional array a[][], where i is the number field element a[i] - value of i-th field in the byte array. The bytes of the fields are interpreted as different types (somewhere stored the bytes of the string, where the bytes of a real number, etc.), and to convert from bytes to string and from string to bytes based on the field type implements the corresponding functions.

I need the display / edit / add / delete items from a List<byte[][]></byte[][]> object properties this class in the DataGrid. Field elements should be presented in columns and rows.

I know about standard binding to the DataGrid through the creation of a separate class and binding it to the ObservableCollection to the DataGrid, but I have a list of items that you want to display in the DataGrid is inside one object, and the elements are not objects of the class, and two-dimensional arrays.

As far as I know, without reference, a purely software event to handle the action on the strings DataGrid'a impossible. Is it possible somehow in another way to work through the DataGrid with my data in its current form? If so, how?
September 26th 19 at 12:02
2 answers
September 26th 19 at 12:04
Offer not DataGrid and ItemsControl to list your parameters.
The outer ItemsControl lists the class property of type List, the second ItemsControl element of this list is of type byte[][], the third is a byte[] and displays a TextBox for each digit.
By binding (Binding) you are changing the values in textboxex, change it in the property of your object.

Xaml:
<window x:class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="MainWindow" height="350" width="525">
<grid>
 <itemscontrol x:name="itemsData">
<itemscontrol.itemtemplate>
<datatemplate>
 <itemscontrol borderbrush="Black" borderthickness="1" itemssource="{Binding}">
<itemscontrol.itemtemplate>
<datatemplate>
 <itemscontrol borderbrush="Black" borderthickness="1" itemssource="{Binding}">
<itemscontrol.itemspanel>
<itemspaneltemplate>
 <stackpanel orientation="Horizontal">
</stackpanel></itemspaneltemplate>
</itemscontrol.itemspanel>
<itemscontrol.itemtemplate>
<datatemplate>
 <textbox text="{Binding Path=.}">
</textbox></datatemplate>
</itemscontrol.itemtemplate>
</itemscontrol>
</datatemplate>
</itemscontrol.itemtemplate>
</itemscontrol>
</datatemplate>
</itemscontrol.itemtemplate>
</itemscontrol>
</grid>
</window>


C#
namespace WpfApplication1
{
 /// <summary>
 /// Logic of interaction for MainWindow.xaml
 /// </summary>
 public partial class MainWindow : Window
{
 public MainWindow()
{
InitializeComponent();
 var my = new MyClass();
 my.Data = new List<byte[][]>();
 my.Data.Add(new byte[][] { new byte[] { 0, 1 }, new byte[] { 2, 3 }, new byte[] { 4, 5 } });
 my.Data.Add(new byte[][] { new byte[] { 6, 7 }, new byte[] { 8, 9 }, new byte[] { 10, 11 } });
 itemsData.ItemsSource = my.Data;
}

}

 public class MyClass
{
 public List<byte[][]> Data
 { get; set; }
}
}</byte[][]></byte[][]>
September 26th 19 at 12:06
It seems to me that the best way to create the ViewModel, which on the one hand bendida in a DataGrid, and on the other syncs with your collection. Of the alternatives, I can suggest to try to use the ListView or GridView c event of the DataGrid.CellEditEnding and DataGrid.RowEditEnding.

Find more questions by tags C#WPF