Search Results

Search found 1 results on 1 pages for 'dommycastles'.

Page 1/1 | 1 

  • Moving an item up and down in a WPF list box

    - by DommyCastles
    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. Here is my code so far: private void btnDataUp_Click(object sender, RoutedEventArgs e) { int selectedIndex = listBoxDatasetValues.SelectedIndex; //get the selected item in the data list if (selectedIndex != -1 && 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 } } I do not know how to swap the values! Any help would be GREATLY appreciated!

    Read the article

1