title: Simple ListView data binding
body: <p>I'm trying to display data in a <code>ListView</code> with WPF and C#, and I'm confused by the different examples and methods I have seen. I'm looking for a fully working example similar to my program, or a list of pre-requisites to make it work. I'll be happy if I manage to display just 1 row of data from my collection. Currently, the list view displays nothing.</p>
  
  <p>C#:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public ObservableCollection&lt;Row&gt; Rows { get; set; }
  
      public MainWindow()
      {
          InitializeComponent();
          Rows = new ObservableCollection&lt;Row&gt;();
          Rows.Add(new Row 
          {
              ID = "42",
              Category = "cat",
              CharLimit = 32,
              Text = "Bonjour"
          });
      }
  }
  
  public class Row
  {
      public string ID { get; set; }
      public string Category { get; set; }
      public int CharLimit { get; set; }
      public string Text { get; set; }
  }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;ListView ItemsSource="{Binding Path=Rows}"&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Width="200" Header="ID" DisplayMemberBinding="{Binding Path=ID}" /&gt;
              &lt;GridViewColumn Width="200" Header="Category" DisplayMemberBinding="{Binding Path=Category}" /&gt;
              &lt;GridViewColumn Width="200" Header="Text" DisplayMemberBinding="{Binding Path=Text}" /&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>Thanks in advance</p>