title: WPF DataGrid DataBinding is not displayed
body: <p>I have a DataGrid in my current WPF Application which I would like to bind to a ViewModel that holds a ObservableCollection. The user can enter search values in some TextBoxes and after enter has been hit I am performing an query to our database that retunrs a table of records. From these records I am populate the data for the ObservableCollection. I am now struggeling now that the datagrid is not displaying the data. </p>
  
  <p>I have read a howl bunch of posts about the binding but I am still missing something I think. </p>
  
  <p><strong>Product.cs</strong></p>
  
  <pre><code>public class Product : InotifyPropertyChanged, IEditableObject
  {
      public string Title { get; set; } = "";
  
      //public Product()
      //{
  
      //}
      private ProductViewModel _productViewModel = new ProductViewModel();
      public ProductViewModel productViewModel { get { return _productViewModel; } set { _productViewModel = value; } }
  
      public DataTable ProductsTable { get; set; }
  
      public void GetProducts(string filter)
      {
          //&lt; --doing some stuff to fill the table--&gt;
  
          foreach (DataRow row in ProductsTable.Rows)
          {
              productViewModel.Products.Add(new Product
              {
  
                  Title = (string)row["TITLE"],
  
              });
          }
      }
  }
  </code></pre>
  
  <p><strong>ProductViewModel.cs</strong></p>
  
  <pre><code>public class ProductViewModel : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
      private Product _SelectedProduct;
      private ObservableCollection&lt;Product&gt; _Products = new ObservableCollection&lt;Product&gt;();
      public ObservableCollection&lt;Product&gt; Products { get { return _Products; } set { _Products = value; } }
  
      public ProductViewModel()
      {
      }
  
      public void NotifyPropertyChanged(string propertyName)
      {
  
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
      }
  }
  </code></pre>
  
  <p><strong>ProductWindow.xaml</strong></p>
  
  <pre><code>&lt;DataGrid 
      Name="ProductsGrid" 
      AutoGenerateColumns="False" 
      ItemsSource="{Binding Products, Mode=TwoWay, NotifyOnSourceUpdated=True}" 
      SelectedItem="{Binding SelectedProduct, Mode=TwoWay}"  
      CanUserAddRows="False" SelectionUnit="FullRow"  
      VerticalAlignment="Stretch" 
      Grid.Row="0" 
      Margin="10,10,10,10" 
      &gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn Binding="{Binding Title}" Header="Title"&gt;&lt;/DataGridTextColumn&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p><strong>ProductWindow.xaml.cs</strong></p>
  
  <pre><code>    public partial class ProductWindow : Page
  {
      public object DialogResult { get; private set; }
      //public ProductViewModel ProductViewModel;
      public ProductWindow()
      {
  
          InitializeComponent();
  
          DataContext = new ProductViewModel();//stackflow
          //var ProductViewModel = products.ProductViewModel;
          //ProductsGrid.DataContext = new ProductViewModel();
  
      }
  
      public ProductViewModel ViewModel =&gt; DataContext as ProductViewModel;
  
      private void OnKeydownHandler(object sender, KeyEventArgs e)
      {
          if (e.Key == Key.Enter)
          {
              var tb = sender as TextBox;
              Product products = new Product();
              string filter = "";//performing some ifelse to create filter
              products.GetProducts(filter);
              //ProductsGrid.DataContext = products.ProductsTable;
              //ProductsGrid.DataContext = products.productViewModel;
  
          }
          else if (e.Key == Key.Escape)
          {
              ProductsGrid.DataContext = null;
              foreach (TextBox tb in FindVisualChildren&lt;TextBox&gt;(this))
              {
                  // do something with tb here
                  tb.Text = "";
              }
          }
      }
  </code></pre>
  
  <p>}</p>