This class is an adorner that allows a FrameworkElement derived class to adorn another FrameworkElement.
Inheritance: System.Windows.Documents.Adorner
コード例 #1
0
        /// <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();
                }
            }
        }
コード例 #2
0
        /// <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;
        }