0

I want to bind some values from 2 dimensional array int[,] into grid. Reading Two way binding between DataGrid and an array I download .dll and add reference. My code is:

part of XAML:

<Grid>
    <dg2d:DataGrid2D Name="dataGrid2D" ItemsSource2D="{Binding Data2D}" Margin="0,0,0,130"/>
</Grid>

and c# behind it:

 public partial class MainWindow : Window
    {
        private int[,] _data2D;
        public int[,] Data2D
        {
            get { return _data2D; }
            set { _data2D = value; }
        }
        public MainWindow()
        {
            int[,] data2D = new int[5,5];
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    data2D[i, j] = 1;
                }
            }
            _data2D = data2D
            dataGrid2D.DataContext = this;
        }
    }

I also read Binding 2d array with WPF DataGrid2D but I don't know how to connect it with my problem? how to connect MainWindow() with view? any help?

Community
  • 1
  • 1
Blabla
  • 367
  • 4
  • 16

1 Answers1

0

Solved: There is need to have dataGrid2D.DataContext = this;

Blabla
  • 367
  • 4
  • 16
  • Ups, I'm sorry, unfortunately did not copied it from a bunch of code. there is "dataGrid2D.DataContext = this;" but error is not solved – Blabla Mar 06 '17 at 15:27