There is also a ListBox button that represents the move up and move down,
The idea is:
Insert a duplicate to the specified position and delete the original one.
Remember, the inserted position will move the back part of it (because it is inserted, so it is inserted in 2, and the original content in 2 will become 3 ......)
The push button is as follows:
View sourceprint?
01.
If (ListBox. selecteditem! = NULL & ListBox. selectedindex! = 0)
02.
{
03.
/// =========================================================== Going up the order (the first pen does not move) ========================================== //
04.
// Add a duplicate item Up In The ListBox
05.
// Duplicate selected
06.
Int CH = ListBox. selectedindex;
07.
ListBox. Items. insert (CH-1, ListBox. items [CH]);
08.
// Delete the old item
09.
ListBox. Items. removeat (CH + 1 );
10.
}
If you can accept the above,
Move down:
View sourceprint?
1.
If (ListBox. selecteditem! = NULL & ListBox. selectedindex! = ListBox. Items. Count-1)
2.
{
3.
/// ===================================================Order down (the last one does not move) ========================================== //
4.
Int CH = ListBox. selectedindex;
5.
ListBox. Items. insert (CH + 2, ListBox. items [CH]);
6.
ListBox. Items. removeat (CH );
7.
}
Why is Unit 2 here? As mentioned above, insertion will move others down. If only the next one is inserted, the original one will be placed behind it. In turn, he wants to move two units.
Congratulations ~
Able to solve this problem within one day ~ (Sprinkling flowers)
In fact, I think there is another way to use binding.
It's just getting started with XAML.TOEFL answer
Although there will be less program code in the hands-on scenarios of XAML,
However, SV is too difficult to understand, so we can use this method now.
By the way, The ListBox of SV is dynamically added to the data, that is, the initially empty ListBox. If binding is used, this method is not guaranteed to be useful ~
C # WPF controls the item sequence of ListBox