I have a stack panel with some user controls that are added or removed at runtime. These elements have an index, which I assign them when I new them, I need these elements to be sorted by this index, so I voted for the quicksort function, which sorts them by index but on a line that does swap
y = items[i];
I get
"The specified index is already in use. First, disable the Visual child with the specified index"
I tried copying them to a temporary variable, removing them from the collection and then assigning them to my right index using the Insert function in the UIElementCollection, but then I get
"The specified visual is already a child of another Visual or CompositionTarget root"
Is there any clone element that I need or is there something missing?
sorting c # wpf stackpanel
irco
source share