private static void SetBackgroundHost(UIElement obj, WindowBackgroundVisualHost value)
 {
     obj.SetValue(BackgroundHostPropertyKey, value);
 }
        static WindowBackgroundVisualHost GetHost(UIElement element)
        {
            var root = element.VisualAncestors().OfType<UIElement>().LastOrDefault();
            if (root == null) return null;

            var host = GetBackgroundHost(root);
            if (host == null)
            {
                var decorator = root.VisualDescendants().OfType<AdornerDecorator>().FirstOrDefault();
                if (decorator != null && decorator.Child != null)
                {
                    host = new WindowBackgroundVisualHost(decorator.Child);
                    if (decorator is BusyAdornerDecorator)
                        ((BusyAdornerDecorator)decorator).BusyIndicatorHost = host;
                    else
                        decorator.AdornerLayer.Add(host);

                    SetBackgroundHost(root, host);
                }
            }

            return host;
        }