/// <summary> /// Internal method to show the adorner. /// </summary> private void ShowAdornerInternal() { if (_adorner != null) { // Already adorned. return; } if (AdornerContent != null) { if (_adornerLayer == null) { _adornerLayer = AdornerLayer.GetAdornerLayer(this); } if (AdornerContent is FrameworkElement) { _adornedFrameworkElement = AdornerContent as FrameworkElement; } else { CreateAdornedFrameworkElementFromDataTemplateInResources(); } if (_adornerLayer != null && _adornedFrameworkElement != null) { _adorner = new FrameworkElementAdorner( _adornedFrameworkElement, this, HorizontalAdornerPlacement, VerticalAdornerPlacement, AdornerOffsetX, AdornerOffsetY); _adornerLayer.Add(_adorner); UpdateAdornerDataContext(); } } }
/// <summary> /// Internal method to hide the adorner. /// </summary> private void HideAdornerInternal() { if (_adornerLayer == null || _adorner == null) { // Not already adorned. return; } _adornerLayer.Remove(_adorner); _adorner.DisconnectChild(); _adorner = null; _adornerLayer = null; }