title: How to select item in ListBox
body: <p>I am trying to select item in ListBox in program, but I was so far unable to do so.</p>
  
  <p>I looked for the answer but everything I found was to use <code>ListBox.SetSelected()</code> method, but I don't have anything like that awaiable.</p>
  
  <p>I discovered that there are two completely different ListBoxes and I am using the second one: </p>
  
  <pre><code>System.Windows.Forms.ListBox
  System.Windows.Controls.ListBox
  </code></pre>
  
  <p>All items in the ListBox are added via Binding, which doesn't help either. Any ideas?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>I just found that this works:</p>
  
  <pre><code>listBox.SelectedIndex = 5;
  listBox.UpdateLayout();
  listBox.Focus();
  </code></pre>
  
  <p>Apparently, I was missing the last method, which sets the highlight to the selected item, which was updating fine even before.</p>