상속: System.Windows.Documents.Adorner
예제 #1
0
        private static void ApplyContentAdorner(FrameworkElement target)
        {
            var adornerLayer = AdornerLayer.GetAdornerLayer(target);

            if (adornerLayer == null)
            {
                // windows do not have an adorner layer, try their first (and only) child
                target = LogicalTreeHelper.GetChildren(target).OfType <FrameworkElement>().FirstOrDefault();
                if (target == null)
                {
                    return;                 // no children found
                }
                adornerLayer = AdornerLayer.GetAdornerLayer(target);
                if (adornerLayer == null)
                {
                    return;                       // nothing adornable found
                }
            }
            var adorner = new ContentAdorner(target);

            adornerLayer.Add(adorner);
        }
예제 #2
0
        private static void ApplyContentAdorner(FrameworkElement target)
        {
            var adornerLayer = AdornerLayer.GetAdornerLayer(target);
            if (adornerLayer == null)
            {
                // windows do not have an adorner layer, try their first (and only) child
                target = LogicalTreeHelper.GetChildren(target).OfType<FrameworkElement>().FirstOrDefault();
                if (target == null) return; // no children found
                adornerLayer = AdornerLayer.GetAdornerLayer(target);
                if (adornerLayer == null) return; // nothing adornable found
            }
            var adorner = new ContentAdorner(target);

            adornerLayer.Add(adorner);
        }