I am currently writing a tool to assign entities from one DataGrid to objects in another DataGrid using drag and drop. With some screaming, I got everything to work smoothly, with one minor annoyance: some entities cannot be tied to any other objects that are not reflected in the user interface (for now).
So, the behavior that I want to achieve is as follows: When the user drags the presenter over another object, the icon should change to the icon "You cannot drop this here" if the entities are incompatible.
This is my code (attached to the DataGridDragDropTarget.DragOver event of the target DataGrid ):
private void DragDropTarget_OnDragOver(object sender, Microsoft.Windows.DragEventArgs e) { var sw = sender as DataGridDragDropTarget; if (sw == null) { return; } if(GetAssignmentCondition(e)) {
What I have tried so far:
I set e.Effects , the DragDropTarget AllowedSourceEffects property and the base ItemDragEventArgs AllowedEffects and Effects to DragDropEffects.None , but to no avail. Googling also did not produce any meaningful results, and I have no ideas.
source share