title: WPF C# Get selected row item Listview
body: <p>I have a popup ListView, declared in this way:</p>
  
  <pre><code>&lt;ListView x:Name="ShowFileLV" 
            ItemsSource="{Binding EmployeeCollection}" 
            DataContext="{Binding}" 
            SelectedItem="{Binding Path=SelectedEmployee}" 
            SelectionMode="Single"&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Width="140" 
                              DisplayMemberBinding="{Binding Name}"&gt;
                  &lt;GridViewColumnHeader Click="SortClick"   
                                        Tag="Name" 
                                        Content="Name" /&gt;
              &lt;/GridViewColumn&gt;
              &lt;GridViewColumn Width="140" 
                              DisplayMemberBinding="{Binding ID}"&gt;
                  &lt;GridViewColumnHeader Click="SortClick"
                                        Tag="ID" 
                                        Content="ID" /&gt;
              &lt;/GridViewColumn&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>The list and the sorting work fine. My problem is that I would like to get the SelectedEmployee directly updated when I select a row (not sure if ListViewItem is the right choice) or even better, to get only the ID or the Name:</p>
  
  <pre><code>public ListViewItem SelectedEmployee
  {
      get
      {
          return _selectedEmployee;
      }
      set
      {
          _selectedEmployee= value;           
      }
  }
  </code></pre>
  
  <p>This was working until I used a ListBox (instead of the ListView) loaded with a List of Strings, each string containing both Name and ID, like this one</p>
  
  <pre><code>&lt;ListBox Name="ShowFileLV" 
           SelectionMode="Single" 
           SelectedValue="{Binding Path=Employee}" 
           Style="{StaticResource ListBoxStyle}" ItemsSource="{Binding Path=ListPopupItems}" &gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>Using a public string like:</p>
  
  <pre><code>public String Employee
  {
      get
      {
          return _employee;
      }
      set
      {
          _employee= value;
          OnPropertyChanged("Employee");
      }
  }
  </code></pre>
  
  <p>When I selected a row it automatically set the public string Employee, without need of code. 
  How can I do his using the ListView and Collections?</p>