/// <summary> /// Handles the SelectionChanged event of the ReorderableListBox control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Controls.SelectionChangedEventArgs"/> instance containing the event data.</param> private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.dragging && !this.dragItemSelected) { this.dragItemSelected = true; this.originalItemIndex = this.SelectedIndex; ListBoxItem listBoxItem = (ListBoxItem)ItemContainerGenerator.ContainerFromIndex(SelectedIndex); this.overlayElement = new DropPreviewAdorner((UIElement)this, listBoxItem); this.overlayElement.Visibility = Visibility.Collapsed; this.AdornerLayer.Add(this.overlayElement); } }