title: Binding a 2 dimensional bool array to datagrid in wpf
body: <p>I have to create a Matrix like datagrid of type bool using 2D Array. I have a set of boolean string that is needed to be evaluated for each cell in the datagrid as follows</p>
  
  <p>for e.g </p>
  
  <p>cell[0,0] = ((server1 || server 2) &amp;&amp; server 3)</p>
  
  <p>cell[0,1] = ((server1 &amp;&amp; server 3) &amp;&amp; server 4)</p>
  
  <p>cell[1,0] = ((server3 &amp;&amp; server 2) || server 4)</p>
  
  <p>the values for server N is Running or Stopped and it is got from the database.</p>
  
  <p>how to create a 2D matrix datagrid and how to evaluate the boolean string so that the final result is TRUE or FALSE for each datagrid cell. </p>
  
  <p>I had a look at this link <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b2731356-180d-4265-8103-fd219565e8ba" rel="nofollow">2D array for string </a>and took this as an example, but I dont know where should I call these evaluation strings. Do I have to store them in an XML file and then call them or is there anyother way to call them..</p>
  
  <p>What I have tried :</p>
  
  <pre><code>public MatrixPage()
  {
  InitializeComponent();
  bool[,] matrixcell = new bool[10, 22];
  
  matrixcell[0, 0] = // should I place the Evaluation string here;
  matrixcell[0, 1] = ;
  for  (int i = 0; i &lt; 10; i++)
  {
  for (int j = 0; j &lt; 22; j++)
  {
   matrixcell[i, j] = // or Should I call here the evaluation boolean string for each    iteration respective to the row/column from a file like XML or a any other file ??
  }
  }
   var datsource = (from i in Enumerable.Range(0, matrixcell.GetLength(0))
      select new clsdatasource(matrixcell[i, 0], matrixcell[i, 1], matrixcell[i,3])).ToList();
   this.dg1.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;
  }
  }
  </code></pre>
  
  <p>XAML</p>
  
  <pre><code>  &lt;Grid&gt;
          &lt;DataGrid x:Name="dg1" CanUserAddRows="False" AutoGenerateColumns="False"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTextColumn Header="System1" Binding="{Binding str1}"/&gt;
                  &lt;DataGridTextColumn Header="System2" Binding="{Binding str2}"/&gt;
                  &lt;DataGridTextColumn Header="System3" Binding="{Binding str3}"/&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>Kindly help.. if the question is not clear to understand, please comment, I will try to explain more clearly</p>