title: Binding the Visibility property of a WPF Datagrid column? Where is my fault?
body: <p>In a loop which sets up my WPF DataGrid columns, I want to bind the column visibility to member 'i' in my 'VisibilityList' with the following code:</p>
  
  <pre><code>var bindingColumnVisibilty = new Binding(string.Format("VisibilityList[{0}]", i));
  BindingOperations.SetBinding(customBoundColumn, DataGridColumn.VisibilityProperty, bindingColumnVisibilty);
  </code></pre>
  
  <p>I have set the DataContext before the loop begins:</p>
  
  <pre><code>TestControlDataGrid.TestDataGrid.DataContext = dataGridSource;
  </code></pre>
  
  <p>The dataGridSource class contains:</p>
  
  <pre><code>public List&lt;Visibility&gt; VisibilityList;
  </code></pre>
  
  <p>This does not appear to work. Have I set up my DataContext and binding correctly? Does it matter that after this loop I set the ItemsSource with the following?</p>
  
  <pre><code>TestDataGrid.ItemsSource = dataGridSource.DataList;
  </code></pre>