title: WPF Binding DataTable column to a textbox
body: <p>I'm getting started with WPF and finding it difficult to get even the most simple binding working.  Here's some givens...</p>
  
  <p>I have an object that queries an existing database and returns a "datatable" object, the data comes back (and for test purposes, only a single row and single column called "MyTextColumn")</p>
  
  <p>The data table is not "Strongly typed" as I've read in other places trying to force the issue of strongly typed objects.  I want to understand the underlying mechanisms from the code-behind perspective, AND not from the XAML perspective.  From reading, apparently you can't bind directly to a data table, but you can to the "DefaultView" of a DataTable object (makes no sense to me since they point to same record (or set of records, with exception of say a filter of some type).</p>
  
  <p>So, in the XAML portion of the window, </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;src:MyWindow blah, blah &gt;
    &lt;Grid Name="grdTesting"&gt;
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition /&gt;
        &lt;ColumnDefinition /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
  
      &lt;Label Name="lblMyTextColumn" 
          Content="Just the label" 
          Grid.Row="0" Grid.Column="0 "/&gt;
  
      &lt;TextBox Name="txtMyTextColumn"
          Grid.Row="0" Grid.Column="1"
          Width="120" /&gt;
    &lt;/Grid&gt;
  &lt;/src:MyWindow&gt;
  </code></pre>
  
  <p>So now, I'm in the code-behind, what I've read is you have to have a BindingListCollectionView oView;</p>
  
  <pre><code>public partial class MyWindow : Window
  {
    BindingListCollectionView oView;
    MyQueryingManager oTestMgr;
  
    public MyWindow()
    {
      InitializeComponent();
  
      oTestMgr = new MyQueryingManager();
      DataTable oResults = oTestMgr.GetTheData();
  
      // Data context for the form bound to the Table retrieved
      oView = new BindingListCollectionView( oResults.DefaultView );
  
      // One place said the Window should get the binding context
      DataContext = oView;
  
      // another indicated the grid...  Just need to know which I SHOULD be using
      grdTesting.DataContext = oView;
  
  
      // Now, for my binding preparation...
      Binding bindMyColumn = new Binding();
      bindMyColumn.Source = oView;
      bindMyColumn.Path = new PropertyPath("MyTextColumn");
      txtMyTextColumn.SetBinding( TextBox.TextProperty, bindMyColumn );
    }
  }
  </code></pre>
  
  <p>So...  what am I missing here... Should be simple, nothing complex, I have a data table, with a record, that has a value.  Run the form (no matter binding context to the Window or the Grid), and the record value does not show in the textbox control.  Once I understand the behavior on a single textbox, I can go on with all the other elements (validation, input mask, formatting, etc), but am stuck right at the gate on this one.</p>
  
  <p>Thanks</p>