title: WPF BindingSource
body: <p>Working on learning WPF by converting one of my applications over from WinForms
  What is the WPF way of doing the following</p>
  
  <pre><code> DataTable _current = _connections.Copy();
   BindingSource _bs = new BindingSource();
   bs.DataSource = _current;
   bs.Filter = "Client = '" + _selectedClient + "'";
  </code></pre>
  
  <p>After the new DataTable table is filtered down, then I would need to assign the binding source to a DataGrid.</p>
  
  <p><em><strong>Update 2</em></strong>
  I have added the following</p>
  
  <pre><code> public ObservableCollection&lt;SupportConnectionData&gt; _supportConnections = new ObservableCollection&lt;SupportConnectionData&gt;();
  </code></pre>
  
  <p>turn the datatable given into ObservableCollection</p>
  
  <pre><code> DataTable _dt = Global.RequestSupportConnections(_token);
                  _dt = Crypto.DecryptDataTable(_dt);
                  ObservableCollection&lt;SupportConnectionData&gt; _connections = new ObservableCollection&lt;SupportConnectionData&gt;();
  
                  foreach (DataRow _row in _dt.Rows)
                  {
                      SupportConnectionData _supportConnection = new SupportConnectionData()
                      {
                          _client = _row["Client"].ToString(),
                          _server = _row["Server"].ToString(),
                          _user = _row["User"].ToString(),
                          _connected = _row["Connected"].ToString(),
                          _disconnected = _row["Disconnected"].ToString(),
                          _reason = _row["Reason"].ToString(),
                          _caseNumber = _row["CaseNumber"].ToString()
                      };
                      _connections.Add(_supportConnection);
                  }
  
                  //let me assign new collection to bound collection
                  App.Current.Dispatcher.BeginInvoke((Action)(() =&gt; { _supportConnections = _connections; }));
                  //this allows it to update changes to ui
                  dgSupportConnections.Dispatcher.BeginInvoke((Action)(() =&gt; { dgSupportConnections.DataContext = _supportConnections; }));
  </code></pre>
  
  <p>XAML</p>
  
  <pre><code>  &lt;DataGrid x:Name="dgSupportConnections" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" AutoGenerateColumns="False" ItemsSource="{Binding}"&gt;
                      &lt;DataGrid.Columns&gt;
                          &lt;DataGridTextColumn Header="Client" Binding="{Binding _client}"/&gt;
                          &lt;DataGridTextColumn Header="Server" Binding="{Binding _server}"/&gt;
                          &lt;DataGridTextColumn Header="User" Binding="{Binding _user}"/&gt;
                          &lt;DataGridTextColumn Header="Connected" Binding="{Binding _connected}"/&gt;
                          &lt;DataGridTextColumn Header="Disconnected" Binding="{Binding _disconnected}"/&gt;
                          &lt;DataGridTextColumn Header="Reason" Binding="{Binding _reason}"/&gt;
                          &lt;DataGridTextColumn Header="Case Number" Binding="{Binding _caseNumber}"/&gt;
                      &lt;/DataGrid.Columns&gt;
                  &lt;/DataGrid&gt;
  </code></pre>