title: WPF ListView Binding ItemsSource in XAML
body: <p>I have a simple XAML page with a ListView on it defined like this</p>
  
  <pre><code>&lt;ListView Margin="10" Name="lvUsers" ItemsSource="{Binding People}"&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Header="Name" Width="120" DisplayMemberBinding="{Binding Name}" /&gt;
              &lt;GridViewColumn Header="Age" Width="50" DisplayMemberBinding="{Binding Age}" /&gt;
              &lt;GridViewColumn Header="Mail" Width="150" DisplayMemberBinding="{Binding Mail}" /&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt; 
  </code></pre>
  
  <p>In the code behind I do:-</p>
  
  <pre><code>public ObservableCollection&lt;Person&gt; People { get; set; }
  
  public ListView()
  {
      InitializeComponent();
  
      this.People = new ObservableCollection&lt;Person&gt;();
      this.People.Add(new Person() { Name = "John Doe", Age = 42, Mail = "john@doe-family.com" });
      this.People.Add(new Person() { Name = "Jane Doe", Age = 39, Mail = "jane@doe-family.com" });
      this.People.Add(new Person() { Name = "Sammy Doe", Age = 7, Mail = "sammy.doe@gmail.com" }); 
  
  }   
  </code></pre>
  
  <p>If I set the ItemsSource of my listview in the code behind like this     </p>
  
  <pre><code>lvUsers.ItemsSource = this.People;
  </code></pre>
  
  <p>it works and my grid is displayed as expected</p>
  
  <p>However if I remove that line and try and bind in the XAML</p>
  
  <pre><code>&lt;ListView Margin="10" Name="lvUsers" ItemsSource="{Binding People}"&gt;
  </code></pre>
  
  <p>it no longer works.  </p>
  
  <p>Why doesn't the binding in the XAML work?</p>