No events reported by WPF adorner layer

I am trying to create a nice drag and drop zone in WPF that appears in the adorner layer when something is being dragged into the main application. The problem is that I do not receive any events from my fan, although according to the documentation he should receive all input events, since he is in a higher z-order.

To debug my problem, I created a really simple example when I have a user control that has only a button. This user control is displayed at the adorner level, but I cannot click a button. What for? What did I do wrong?

My adorner class is constructed as follows:

    public ShellOverlayAdorner(UIElement element, AdornerLayer adornerLayer)
        :base(element)
    {
        _adornerLayer = adornerLayer;

        _overlayView = new AdornedElement();
        _overlayView.AllowDrop = true;
        _adornerLayer.Add(this);
     }

and is created in the main window

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        adornerLayer = AdornerLayer.GetAdornerLayer(MyTopGridWithButtonInIt);
        ShellOverlayAdorner shell = new ShellOverlayAdorner(MyTopGridWithButtonInIt, adornerLayer);

    }

- , .. , , . adorner. ?

+5
2

, : , , , , adorner. - VisualCollection, , , , :

    VisualCollection visualChildren;
    FrameworkElement @object;

    public CustomAdorner(UIElement adornedElement) :
        base(adornedElement)
    {
        visualChildren = new VisualCollection(this);
        @object = new Button {Content = "prova"};
        visualChildren.Add(@object);
    }
    protected override Visual GetVisualChild(int index)
    {
        return visualChildren[index];
    }

, .

+11

. MSDN, :

Adorners FrameworkElement. adorner z-, , , adorner (, Drop MouseMove), . .

adorner, IsHitTestVisible false adorner.

i.e adorner , IsHitTestVisible = false

+1

All Articles