简体   繁体   中英

WPF Grid not working properly for drag and drop

I am working with an application that uses drag and drop operations of grids. The application is backed by a List of objects. When a grid is dropped, the children of the grid(my data) are added to the list. So essentially it is a List but that is not really that important.

Each Grid contains two inner grids. The first grid contains a label, and the second contains a component such as a TextBox, or a DropDown box.(It is a drag and drop editor for building HTML Forms).

I am working on making it easier for the user to see when they drag over the grids if they are going to drop above, below or on the element by checking the position of the mouse while they are dragging over the grid elements.

The problem I am running into is that the DragOver,DragDrop,etc are only firing when I drag over the child elements of the grids. I have tried to go from bubbling to tunneling and vice versa but I cant figure it out.

Is there something I need to set on the Grid Element that allows the entire Grid to accept drops?

Try setting the background of your grids to a transparent brush. In this case I'm not sure if this is the problem, but for most mouse operations such as hit tests, you have to attach a background even if it is transparent.

<Grid Background="Transparent" ... />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM