title: How to show a table in a WPF
body: <p>I need help with a simple project I am doing in Visual Studio just to learn coding a little bit. I would like to show a table containing objects from a class called Car in a WPF, and this table should be done programmatically.</p>
  
  <p>So, I added a ListView in MainWindow.xaml and set the name for GridView to GridView1 </p>
  
  <pre><code>&lt;Window x:Class="Test.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;ListView HorizontalAlignment="Center" Height="100" Margin="0,10,0,0" VerticalAlignment="Top" Width="100"&gt;
              &lt;ListView.View&gt;
                  &lt;GridView x:Name="GridView1"&gt;
                      &lt;GridViewColumn/&gt;
                  &lt;/GridView&gt;
              &lt;/ListView.View&gt;
          &lt;/ListView&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>In the MainWindow.xaml.cs I did this</p>
  
  <pre><code>using System;
  ...
  //Add this to use DataTable
  using System.Data;
  
  namespace Test
  {
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
  
              //create some objects
              Car ferrari = new Car("Ferrari","Front-Wheel");
              Car mercedes = new Car("Mercedes","Rear-Wheel");
  
              //create a DataTable
              DataTable dt = new DataTable();
              //add 2 columns
              dt.Columns.Add("Vehicle Name");
              dt.Columns.Add("Vehicle Drive");
              //add 2 rows
              dt.Rows.Add(ferrari.Name, ferrari.Drive);
              dt.Rows.Add(mercedes.Name, mercedes.Drive);
              //bind it to GridView
              GridView1.DataSource = dt;
              GridView1.DataBind();          
          }
      }
  }
  </code></pre>
  
  <p>The problem are the last 2 lines, Visual Studio says it does not contain a definition nor extension method for 'DataSource' and 'DataBind', but all the examples I saw online make use of them. Where is the mistake?  </p>