title: Wpf add a click function to items in listview
body: <p>Xaml:</p>
  
  <pre><code>&lt;Window x:Class="Berichtensysteem.Window1"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:local="clr-namespace:Berichtensysteem"
              mc:Ignorable="d"
              Title="Mailclient" Height="800" Width="800"
              &gt;
  
          &lt;Grid&gt;
  
              &lt;UserControl&gt;
                  &lt;Grid Margin="0,-10,177,10"&gt;
                      &lt;Button x:Name="inboxClick" Content="Inbox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="121" Margin="1,56,0,0"/&gt;
                      &lt;Button x:Name="outbox" Content="Verzonden berichten" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Margin="1,96,0,0"/&gt;
                      &lt;Button x:Name="deleted" Content="Verwijderde berichten" HorizontalAlignment="Left" VerticalAlignment="Top" Width="121" Margin="1,76,0,0"/&gt;
  
                  &lt;/Grid&gt;
              &lt;/UserControl&gt;
  
  
              &lt;ListView Margin="126,45,0,0" Name="inbox"&gt;
                  &lt;ListView.View&gt;
                      &lt;GridView&gt;
                          &lt;GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" /&gt;
                          &lt;GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" /&gt;
                          &lt;GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" /&gt;
                      &lt;/GridView&gt;
                  &lt;/ListView.View&gt;
              &lt;/ListView&gt;
          &lt;/Grid&gt;
      &lt;/Window&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>    public partial class Window1 : Window
      {
          private static databaselinkDataContext _dataDC = new databaselinkDataContext();
          public Window1(String username)
          {
              InitializeComponent();
              sendMail();
  
  
  
              List&lt;email&gt; _mails = _dataDC.emails.ToList();
              inbox.ItemsSource = _mails;
  
          }
  
  // Adding an email to the database because I haven't set up send mails yet.
  
          public void sendMail()
          {
              var _email = new email();
              _email.content = "Mijn inhoud";
              _email.from = "hallo";
              _email.subject = "myemailsubject";
              _email.layout = "";
  
              _dataDC.emails.InsertOnSubmit(_email);
              _dataDC.SubmitChanges();
          }
      }
  }
  </code></pre>
  
  <p>So. I have my mails, I've managed to display them on the screen with a listview. I want to show the full content of the e-mail once it is clicked. To do this I need to things:</p>
  
  <ol>
  <li>Add a click listener to each listview item (similar to recyclerview in android?).</li>
  <li>Replace the listview with the contents of the email, while maintaining my usecontrol.</li>
  </ol>
  
  <p>Any simple way to do this?</p>