title: Reading a .csv file into WPF application (C#)
body: <p>I've just recently made a C# console application that could read a .csv file and write it to the console in a neat manner, however now I want to make it in WPF to make it even more neat.</p>
  
  <p>My previous console application looks like this:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          string[] tokens;
          char[] separators = { ';' };
          string str = "";
  
          FileStream fs = new FileStream(@"D:\Dokumenter\Skole\6. semester\GUI\Exercises\Exercise2\02 deltagerliste.csv", 
                                         FileMode.Open);
          StreamReader sr = new StreamReader(fs, Encoding.Default);
  
          while ((str = sr.ReadLine()) != null)
          {
              tokens = str.Split(separators, StringSplitOptions.RemoveEmptyEntries);
  
              Console.WriteLine(String.Format("{0,-20}", tokens[0]) +
                                String.Format("{0,-15}", tokens[1]) +
                                String.Format("{0,-15}", tokens[2]) +
                                String.Format("{0,-15}", tokens[3]));
          }
  
          Console.ReadLine();            
      }
  }
  </code></pre>
  
  <p>It works great, but I must admit that I have difficulties finding out where to begin with the WPF application.</p>
  
  <p>So far I have conjured up the following XAML code with the four headers of the .csv file (since it has four columns) and I assume I have to find a way to put the appropriate rows into the respective columns. </p>
  
  <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Deltagerliste" Height="350" Width="525" WindowStartupLocation="CenterScreen" WindowState="Maximized"
      Background="DeepPink"
      &gt;
  &lt;ListView HorizontalAlignment="Left" Height="320" VerticalAlignment="Top" Width="517"&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Header="First name"/&gt;
              &lt;GridViewColumn Header="Last name"/&gt;
              &lt;GridViewColumn Header="ID"/&gt;
              &lt;GridViewColumn Header="Email"/&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p></p>
  
  <p>My main and initial problem is how I read in the file to the ListView. I'm new to both C# and XAML and even though I'm well aware of how to open and read a file in C#, the syntax in XAML is a little confusing to me.</p>