Skip to content

Drag events are not raised on elements below an AllowDrop ancestor (AllowDrop isn't inherited) #25275

Open

Description

@MartinZikmund

Current behavior 🐛

UIElement.AllowDrop is a plain (non-inherited) dependency property in Uno. As a result, DragEnter/DragOver/DragLeave/Drop are only raised on elements that set AllowDrop=true themselves. Elements between the pointer and the AllowDrop ancestor are skipped, even though the drag is hit-tested into them.

Observed on Skia Desktop (Win32): with parent (AllowDrop=true) > child > leaf, dragging over leaf raises DragOver on parent (2 times) but 0 times on child.

A visible consequence: in a ListView with AllowDrop=true, ListViewItem containers never receive DragOver, so ListViewBaseItem.OnDragOver and the item DragOver visual state never run unless the item container sets AllowDrop=true itself.

Expected behavior 🎯

In WinUI, AllowDrop is an inherited property: descendants of an AllowDrop=true element have AllowDrop == true and receive the drag events as they bubble from the element under the pointer. This is source-backed (see below), not runtime-backed. WinUI's own ListViewBaseItem::OnDragOver relies on that, since ListViewItem's default style does not set AllowDrop.

How to reproduce it (as minimally and precisely as possible) 🔬

Runtime test (Skia Desktop, goes in Given_UIElement next to When_DragEnter_Fires_Along_DragStarting):

[TestMethod]
[RunsOnUIThread]
public async Task When_DragOver_On_Intermediate_Element_Of_AllowDrop_Parent()
{
    var injector = InputInjector.TryCreate() ?? throw new InvalidOperationException();
    using var mouse = injector.GetMouse();
    mouse.MoveTo(Windows.Foundation.Point.Zero);
    await TestServices.WindowHelper.WaitForIdle();

    var leaf = new Border { Width = 100, Height = 100, Background = new SolidColorBrush(Microsoft.UI.Colors.Red) };
    var child = new Border { Child = leaf };
    var parent = new Border { Padding = new Thickness(20), AllowDrop = true, Background = new SolidColorBrush(Microsoft.UI.Colors.Blue), Child = child };
    var childDragOver = 0;
    var parentDragOver = 0;
    child.DragOver += (_, args) => { args.AcceptedOperation = DataPackageOperation.Copy; childDragOver++; };
    parent.DragOver += (_, _) => parentDragOver++;

    var source = new Border { Width = 50, Height = 50, CanDrag = true, Background = new SolidColorBrush(Microsoft.UI.Colors.Green) };
    source.DragStarting += (_, e) => e.Data.SetText("test");

    await UITestHelper.Load(new StackPanel { Children = { source, parent } });

    mouse.MoveTo(source.GetAbsoluteBoundsRect().GetCenter());
    mouse.Press();
    await TestServices.WindowHelper.WaitForIdle();

    var target = leaf.GetAbsoluteBoundsRect().GetCenter();
    mouse.MoveTo(new Windows.Foundation.Point(target.X, target.Y - 10), 1);
    await TestServices.WindowHelper.WaitForIdle();
    mouse.MoveTo(target, 1);
    await TestServices.WindowHelper.WaitForIdle();

    Assert.IsTrue(parentDragOver > 0);  // passes (2)
    Assert.IsTrue(childDragOver > 0);   // fails (0)
}

Steps: run that test on master (Skia Desktop). parentDragOver is 2, childDragOver is 0.

Note: if the handler is on the element directly under the pointer (the leaf itself), it does fire. Only elements in between are skipped.

Workaround 🛠️

Set AllowDrop=true on every element that needs the events, e.g. via ItemContainerStyle for list items.

Affected platforms 📱💻🖥️

Skia (verified on Desktop/Win32; the code path is shared by all Skia heads).

Uno.Sdk version (and other relevant versions) 📦

Uno master at 951b7b4, net11.0-desktop.

Anything else we need to know? 💬

Root cause (code inspection plus the runtime test above):

WinUI (C++ sources in microsoft-ui-xaml): UIElement_AllowDrop is listed among the inherited properties in InheritedProperties.cpp, and ListViewBaseItem::OnDragOver handles DragOver on items of an AllowDrop list without any item-level AllowDrop.

Suggested fix: register AllowDrop with FrameworkPropertyMetadataOptions.Inherits and check that PrepareManagedDragAndDropEventBubbling, DropUITarget and the ListView reorder code still behave (the existing drag and drop runtime tests cover most of it). A fix is in progress.

Activity

  1. added
    kind/bug
    triage/untriaged
    area/skia ✏️
    project/input ⌨️
    difficulty/medium 🤔
    area/drag-drop
    platform/desktop 🖥️
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/drag-droparea/skia ✏️difficulty/medium 🤔kind/bugplatform/desktop 🖥️project/input ⌨️triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions