This helps in situations with TextBox
and FlowDocument
controls, so it should work with DataGrid
.
The key here is to set the event to Handled
to keep the control from doing its shenanigans.
Something like so:
Code behind (just for demonstration - preferably use a more MVVM friendly solution):
private void DragDropTarget_DragEnter(object sender, Microsoft.Windows.DragEventArgs e)
{
var sw = sender as DataGridDragDropTarget;
if (sw == null)
{
return;
}
if(GetAssignmentCondition(e))
{
// TODO: Show link-icon
e.Effects = DragDropEffects.Link;
}
else
{
// TODO: Show drop-disabled-icon
e.Effects = DragDropEffects.None;
}
// Add this
e.Handled = true;
}