title: WPF ListView Cannot Trigger Selection Changed when only one row
body: <p>I have a listview which has its datasource changed after update of a search textbox.</p>
  
  <p>When I enter search criteria that only returns one row, I am unable to trigger the OnSelectionChanged event The listbox works as expected at any other time.</p>
  
  <p>I have tried changing SelectedItem and SelectedIndex in Code, Clicking aimlessly on the ListView both on and off the row and are at the brink of insanity.  </p>
  
  <p>Does anyone know of a solution so that I am able to change the selected item!!  Help Please</p>
  
  <p>The code I want to run (somehow) is:</p>
  
  <pre><code>private void lstShedBatch_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
  try{               
      if (lstShedBatch.SelectedItem != null &amp;&amp; lstShedBatch.SelectedIndex != -1)
       {
         ShedBatch currShedBatch = (ShedBatch)this.ShedBatchView.CurrentItem;
         Window1.ShedBatchId = currShedBatch.ShedBatchId;
         Window1.selectedShedId = currShedBatch.ShedId;
  
         RoutedEventArgs args = new RoutedEventArgs(selectShedBatchClickEvent);
                  RaiseEvent(args);
          }
         }
        catch
         {
         }
      }
  </code></pre>
  
  <p>The problem as stated above, is that this event does not get triggered if the number of items in the list =0 or 1.  If there is one record, i want to know what it is and use it to pass variables.</p>