title: ListBox won't remove the first item in c#
body: <pre><code>private void button_Click(object sender, RoutedEventArgs e) //ADD
  {
      listBox.Items.Add("some");
      listBox.Items.Add("text");         
  
  }
  
  
  private void button1_Click(object sender, RoutedEventArgs e) //DELETE
  {
  
      if (!(listBox.SelectedIndex == -1))
         listBox.Items.Remove(listBox.SelectedItem);
      else
          System.Windows.MessageBox.Show("You have not selected an item");
  
  }
  </code></pre>
  
  <p>The <code>ListBox</code> won't delete the first item sometimes. The reason is that after I delete an item a white border appears on the previous item. I don't know why this border appears. See Image to see what I mean. When the white border appears and I try to delete the first item, it says that I have not selected an item. <strong>If I save 3 times the same item and delete the second, the bug appears.</strong> </p>
  
  <p>Try it out. for example some, some,some</p>
  
  <p><img src="https://i.stack.imgur.com/j0nMh.png" alt="enter image description here"></p>