or
public virtual void BringToFront(){ // FindIndexToAdd finds an index for a new item, not for old which needs to be moved. That's why we subtract 1. var targetIndex = this.FindIndexToAdd() - 1; var currentIndex = hosts.IndexOf(this); if (targetIndex != currentIndex) { hosts.RemoveAt(currentIndex); hosts.Insert(targetIndex, this); }}public virtual void BringToFront() { // FindIndexToAdd finds an index for a new item, not for old which needs to be moved. That's why we subtract 1. var targetIndex = this.FindIndexToAdd() - 1; var currentIndex = hosts.IndexOf(this); if (targetIndex != currentIndex && targetIndex > 0) { if (currentIndex > 0) hosts.RemoveAt(currentIndex); hosts.Insert(targetIndex, this); }}
