I have a datagrid in my application and I would like to bind multidimensional array of bool items to the grid.
how to bind the following items to the datagrid ItemsSource ?
for e.g
bool[,] matrix = new bool[10, 22];
matrix[0, 1] = true;
matrix[0, 2] = false;
matrix[0, 3] = true;
matrix[1, 1] = false;
matrix[1, 3] = true;
What i have tried, and I see an empty datagrid
public MatrixPage()
{
InitializeComponent();
bool[,] matrix = new bool[5, 5];
matrix[0, 1] = true;
matrix[0, 2] = false;
matrix[0, 3] = true;
var datsource = (from i in Enumerable.Range(0, matrix.GetLength(0))
select new clsdatasource(matrix[0, 1], matrix[0, 2], matrix[0, 3])).ToList();
Matrix_datagrid.ItemsSource = datsource;
}
public class clsdatasource
{
public bool str1 { get; set; }
public bool str2 { get; set; }
public bool str3 { get; set; }
public clsdatasource(bool s1, bool s2, bool s3)
{
this.str1 = s1;
this.str2 = s2;
this.str3 = s3;
}
}
}
