title: Moving an item up and down in a WPF list box
body: <p>I have a list box with a bunch of values in it. I also have an UP button and a DOWN button.
  With these buttons, I would like to move the selected item in the list box up/down. I am having trouble doing this.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>    private void btnDataUp_Click(object sender, RoutedEventArgs e)
      {
  
          int selectedIndex = listBoxDatasetValues.SelectedIndex; //get the selected item in the data list
  
          if (selectedIndex != -1 &amp;&amp; selectedIndex != 0) //if the selected item is selected and not at the top of the list
          {
              //swap items here
              listBoxDatasetValues.SelectedIndex = selectedIndex - 1; //keep the item selected
          }
  
  
      }
  </code></pre>
  
  <p>I do not know how to swap the values! Any help would be GREATLY appreciated!</p>