private void RemoveInsertionAdorner() { if (_insertionAdorner != null) { _insertionAdorner.Detach(); _insertionAdorner = null; } }
private void CreateInsertionAdorner() { if (_targetItemContainer != null) { // Here, I need to get adorner layer from targetItemContainer and not targetItemsControl. // This way I get the AdornerLayer within ScrollContentPresenter, and not the one under AdornerDecorator (Snoop is awesome). // If I used targetItemsControl, the adorner would hang out of ItemsControl when there's a horizontal scroll bar. _insertionAdorner = new InsertionAdorner( // If the target is vertical, the adorner should be horizontal _targetOrientation == Orientation.Horizontal ? Orientation.Vertical : Orientation.Horizontal, _isInFirstHalf ? RelativePosition.Before : RelativePosition.After, _targetItemContainer, AdornerLayer.GetAdornerLayer(_targetItemContainer)); } }